<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Exponential expression</title> </head> <body><div class="manualnavbar" 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" id="refsect1-function.pow-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"><strong>pow</strong></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.number" class="type number">number</a></span> <code class="parameter">$base</code></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.number" class="type number">number</a></span> <code class="parameter">$exp</code></span> )</div> <p class="para rdfs-comment"> Returns <em><code class="parameter">base</code></em> raised to the power of <em><code class="parameter">exp</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.pow-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">base</code></em></span> <dd> <p class="para"> The base to use </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">exp</code></em></span> <dd> <p class="para"> The exponent </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.pow-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <em><code class="parameter">base</code></em> raised to the power of <em><code class="parameter">exp</code></em>. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> type, otherwise it will be returned as a <span class="type"><a href="language.types.float.html" class="type float">float</a></span>. </p> </div> <div class="refsect1 changelog" id="refsect1-function.pow-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>4.2.0</td> <td> No warning is emitted on errors, even if the value can't be computed. </td> </tr> <tr> <td>4.0.6</td> <td> The function will now return <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> results if possible, before this it always returned a <span class="type"><a href="language.types.float.html" class="type float">float</a></span> result. For older versions, you may receive a bogus result for complex numbers. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.pow-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3471"> <p><strong>Example #1 Some examples of <span class="function"><strong>pow()</strong></span></strong></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 notes" id="refsect1-function.pow-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> This function will convert all input to a number, even non-scalar values, which could lead to <em>weird</em> results. </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.pow-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.exp.html" class="function" rel="rdfs-seeAlso">exp()</a> - Calculates the exponent of e</span></li> <li class="member"> <span class="function"><a href="function.sqrt.html" class="function" rel="rdfs-seeAlso">sqrt()</a> - Square root</span></li> <li class="member"> <span class="function"><a href="function.bcpow.html" class="function" rel="rdfs-seeAlso">bcpow()</a> - Raise an arbitrary precision number to another</span></li> <li class="member"> <span class="function"><a href="function.gmp-pow.html" class="function" rel="rdfs-seeAlso">gmp_pow()</a> - Raise number into power</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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>