PHPerKaigi 2025

sqrt

(PHP 4, PHP 5, PHP 7, PHP 8)

sqrtSquare root

Açıklama

sqrt(float $num): float

Returns the square root of num.

Bağımsız Değişkenler

num

The argument to process

Dönen Değerler

The square root of num or the special value NAN for negative numbers.

Örnekler

Örnek 1 sqrt() example

<?php
// Precision depends on your precision directive
echo sqrt(9); // 3
echo sqrt(10); // 3.16227766 ...
?>

Ayrıca Bakınız

add a note

User Contributed Notes 1 note

up
0
landavia81 at gmail dot com
2 days ago
if you want a custom square root. Use pow() or powLogExp function (custom).

example:
100 root 3. In math is same as 1 divide with 3 (important)
<?php
$root
= 1/3;
echo
pow(1000, $root);
echo
powLogExp(1000, $root);

function
powLogExp($num1, $num2){
$num3 = log($num1) * $num2;
return
exp($num3);
}
?>
With this, you might using more complex 'root'
reference: counting math using log
To Top