What is bcpow in PHP?
bcpow is a function in PHP that calculates the value of the arbitrary precision number raised to the power of another number.
Syntax
bcpow(string $num, string $exp, int $scale = null): string
Parameters
-
num- It is the base number.numis of typestring. -
exp- It is the exponent.expis of the integer type. -
scale- variable of typeint. It is an optional parameter.scaleis used to set the number of digits after the decimal place in the result. The default value ofscaleis 0.
Return value
The function returns the value of num raised to the exp. The value returned is of type string.
Code
<?php$num1 = '4.2';$num2 = '3';echo bcpow($num1, $num2);echo bcpow($num1, $num2, 2);?>
Expected output
74
74.08