PHP - pow
Trieda
Metóda - pow
(PHP 4, PHP 5, PHP 7)
The pow() function returns base raised to the power. We can
easily replace it by simple multiplication what is more effective for lower
exponents.
Procedurálne
- function pow (number $base, number $exp) : number
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $base | number | The base. | |
| $exp | number | The exponent. |
Mávratovej hodnoty
Vracia: number
Base raised to the power.
Príklady
<?php
for ($i = 0; $i < 10; $i++) {
$x = rand(3, 15); // generates a random integer from 3 to 15
$y = rand(5, 20);
$output = pow($x, $y); // x raised to y
echo ("$x^$y = $output <br />");
}
