📄 function.md5.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Calculate the md5 hash of a string</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.md5-file.html">md5_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.metaphone.html">metaphone</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.md5" class="refentry"> <div class="refnamediv"> <h1 class="refname">md5</h1> <p class="verinfo">(PHP 4, PHP 5, PECL hash:1.1-1.3)</p><p class="refpurpose"><span class="refname">md5</span> — <span class="dc-title">Calculate the md5 hash of a string</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>md5</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$raw_output</tt></span> ] )</div> <p class="para rdfs-comment"> Calculates the MD5 hash of <i><tt class="parameter">str</tt></i> using the <a href="http://www.faqs.org/rfcs/rfc1321" class="link external">» RSA Data Security, Inc. MD5 Message-Digest Algorithm</a>, and returns that hash. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">str</tt></i></span> <dd> <p class="para"> The string. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">raw_output</tt></i></span> <dd> <p class="para"> If the optional <i><tt class="parameter">raw_output</tt></i> is set to <b><tt>TRUE</tt></b>, then the md5 digest is instead returned in raw binary format with a length of 16. Defaults to <b><tt>FALSE</tt></b>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the hash as a 32-character hexadecimal number. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.0</td> <td colspan="1" rowspan="1" align="left"> The <i><tt class="parameter">raw_output</tt></i> parameter was added. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>md5()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'apple'</span><span style="color: #007700">;<br /><br />if (</span><span style="color: #0000BB">md5</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">) === </span><span style="color: #DD0000">'1f3870be274f6c49b3e31a0c6728957f'</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Would you like a green or red apple?"</span><span style="color: #007700">;<br /> exit;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.sha1-file.html" class="function" rel="rdfs-seeAlso">sha1_file()</a></li> <li class="member"><a href="function.crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a></li> <li class="member"><a href="function.sha1.html" class="function" rel="rdfs-seeAlso">sha1()</a></li> <li class="member"><a href="function.hash.html" class="function" rel="rdfs-seeAlso">hash()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.md5-file.html">md5_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.metaphone.html">metaphone</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -