PHP pow() Function – Exponential Expression
The PHP pow() function returns the base raised to the exponent, optionally yielding an integer, and its usage is illustrated with examples showing integer, zero, negative, and floating‑point exponent cases, including version‑specific behavior for PHP 4.0.6 and later.
The pow() function in PHP calculates the power of a base number raised to an exponent and returns the result, attempting to return an integer when possible.
Signature:
number pow(number $base, number $exp)Parameters
$base – The base number.
$exp – The exponent.
Return value
The value of $base raised to the power of $exp . May be an integer if the result fits.
Examples
<?php
var_dump(pow(2, 8)); // int(256)
echo pow(-1, 20); // 1
echo pow(0, 0); // 1
echo pow(-1, 5.5); // PHP >4.0.6 NAN
echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND
?>Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.