📄 function.pow.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Exponential expression</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.pi.html">pi</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.rad2deg.html">rad2deg</a></div> <div class="up"><a href="ref.math.html">Math Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.pow" class="refentry"> <div class="refnamediv"> <h1 class="refname">pow</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">pow</span> — <span class="dc-title">Exponential expression</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.number" class="type number">number</a></span> <span class="methodname"><b><b>pow</b></b></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.number" class="type number">number</a></span> <tt class="parameter">$base</tt></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.number" class="type number">number</a></span> <tt class="parameter">$exp</tt></span> )</div> <p class="para rdfs-comment"> Returns <i><tt class="parameter">base</tt></i> raised to the power of <i><tt class="parameter">exp</tt></i>. </p> <div class="warning"><b class="warning">Warning</b> <p class="para"> In PHP 4.0.6 and earlier <b>pow()</b> always returned a <a href="language.types.float.html" class="type float">float</a>, and did not issue warnings. </p> </div> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">base</tt></i></span> <dd> <p class="para"> The base to use </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">exp</tt></i></span> <dd> <p class="para"> The exponent </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <i><tt class="parameter">base</tt></i> raised to the power of <i><tt class="parameter">exp</tt></i>. If the result can be represented as integer it will be returned as type <a href="language.types.integer.html" class="type integer">integer</a>, else it will be returned as type <a href="language.types.float.html" class="type float">float</a>. If the power cannot be computed <b><tt>FALSE</tt></b> will be returned instead. </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">Since 4.0.6</td> <td colspan="1" rowspan="1" align="left"> The function will now return <a href="language.types.integer.html" class="type integer">integer</a> results if possible, before this it always returned a <a href="language.types.float.html" class="type float">float</a> result. For older versions, you may receive a bogus result for complex numbers. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">Since 4.2.0</td> <td colspan="1" rowspan="1" align="left"> PHP stops to emit a warning if the value can't be computed, it will now silently return <b><tt>FALSE</tt></b> only. </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 Some examples of <b>pow()</b></b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">pow</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">)); </span><span style="color: #FF8000">// int(256)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">pow</span><span style="color: #007700">(-</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">); </span><span style="color: #FF8000">// 1<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">pow</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">); </span><span style="color: #FF8000">// 1<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">pow</span><span style="color: #007700">(-</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">5.5</span><span style="color: #007700">); </span><span style="color: #FF8000">// PHP >4.0.6 NAN<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">pow</span><span style="color: #007700">(-</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">5.5</span><span style="color: #007700">); </span><span style="color: #FF8000">// PHP <=4.0.6 1.#IND<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.exp.html" class="function" rel="rdfs-seeAlso">exp()</a></li> <li class="member"><a href="function.sqrt.html" class="function" rel="rdfs-seeAlso">sqrt()</a></li> <li class="member"><a href="function.bcpow.html" class="function" rel="rdfs-seeAlso">bcpow()</a></li> <li class="member"><a href="function.gmp-pow.html" class="function" rel="rdfs-seeAlso">gmp_pow()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pi.html">pi</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.rad2deg.html">rad2deg</a></div> <div class="up"><a href="ref.math.html">Math 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 + -