<!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, PHP 7)</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 <code class="parameter">base</code> raised to the power of <code class="parameter">exp</code>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> In PHP 5.6 onwards, you may prefer to use the <a href="language.operators.arithmetic.html" class="link">**</a> operator. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.pow-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter">base</code></dt> <dd> <p class="para"> The base to use </p> </dd> <dt> <code class="parameter">exp</code></dt> <dd> <p class="para"> The exponent </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.pow-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <code class="parameter">base</code> raised to the power of <code class="parameter">exp</code>. 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 examples" id="refsect1-function.pow-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4267"> <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 /></span><span style="color: #007700">echo </span><span style="color: #0000BB">pow</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">, -</span><span style="color: #0000BB">1</span><span style="color: #007700">); </span><span style="color: #FF8000">// 0.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 >=5.2.2: 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 <5.2.2: -NAN<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>