??? n????? ??? ????? ?? ?? ?? ????? ????? PHP?? ??? ???? ??? ???. pow(), log() ?? ?? ??? ??? ???? ??? ?? ?????.
??
? ?????? ?? ?? ??
PHP ??? - ?? ?? | 8? ?? ??? | 3?? ????
?? ????? ?? ?? ??
? ??, ????? ??, ????? ??? ?
PHP? ?? ????? ????? ?? ??? ?? ???? ???? ???? ?? ?????. ? ??? sqrt()???. ?? sqrt()? ???? ?? ??? ???? ?? ??? ??? ??? ?? ??? ???? ???? ???? ??? ?????.
sqrt() ??? ??? ??? ???? ???? ? ?????. ? ??? pow(), rand(), is_nan() ?? ?? PHP?? ???? ?? ?? ?????.
??? ??
??? ??? ??? ??? ??? ??? ???? ????.
??:
sqrt($num)
??? $num? sqrt ??? ???? ?? ?????.
??:?sqrt() ??? ??? ??? ???? ???? ?????. ??? ?? float ?????. ?? ??? ??? ??? ??? ???? ??? ???? ??? ??? ?? ??? ????.
??? ?? ??? ??, ??, ??(?? ???) ?? 0? ?? ??? ? ? ????. ??? ??? ???? ???? ??? NAN(??? ??)? ???? ?????. ??? ???? ???? ?? ????? 1? ???? 1???. ?? 0? ???? 0??? ?? ?????.
??? ??? ??? ???
??? ??? ???? ??? ????.
?? ??? 81?? ??? ???? 9? ??, ?? ??? 49?? ???? 7? ?? ????.
?? ?? ???????.
?? ??? ?? ??? ?? ???? ??? ??? ?????.
?? #1
??:
<?php
// simple example to find how sqrt() function works on numbers
echo sqrt(16);
echo '<br>';
// output is 4
echo sqrt(7);
echo '<br>';
//output is 2.6457513110646
?>
??:

? ?????? ??? 4???. 4*4? 16??? 16? ???? 4???. 7? ???? ???? ?? ??? ?? ???? ?? ???? ?? ? ? ????. ??? ?? ???? ???? ?? ????.
??? ??? ???? ???? sqrt ??? ?????. ??? ??? ?? ????? ????? ???? pow() ??? ?????.
?? #2
?? :
<?php
// example to calculate any root
echo '<br>'.'Result of? :?? pow(16, 1/2)? ======? '. pow(16, 1/2);
// example to calculate the cube root of 27
echo '<br>'.'Result of? : pow(27, 1/3)? ======? '. pow(27, 1/3);
//example to calculate the fourth root of 12
echo '<br>'.'Result of? : pow(12, 1/4)? ======? '. pow(12, 1/4);
//example to calculate the fifth root of 76
echo '<br>'.'Result of? : pow(76, 1/5)? ======? '. pow(76, 1/5);
//example to calculate the sixth root of 88
echo '<br>'.'Result of? : pow(88, 1/6)? ======? '. pow(88, 1/6);
?>
??:

?? #3
??:
<?php
echo '<br>'.'Result of? :?? sqrt(625)? ======? '. sqrt(625);
echo '<br>'.'Result of? :?? sqrt(49)? ======? '. sqrt(49);
echo '<br>'.'Result of? :?? sqrt(-36)? ======? '. sqrt(-36);
echo '<br>'.'Result of? :?? sqrt(0)? ======? '. sqrt(0);
echo '<br>'.'Result of? :?? sqrt(121)? ======? '. sqrt(121);
echo '<br>'.'Result of? :?? sqrt(22)? ======? '. sqrt(22);
echo '<br>'.'Result of? :?? sqrt(12.34)? ======? '. sqrt(12.34);
echo '<br>'.'Result of? :?? sqrt(-16)? ======? '. sqrt(-16);
?>
??:

?? #4
???? ??? ?? ??? ??? ??? ??: ?? ??????? ???? ??? ?? ??? ??? ???? ???? ????? PHP? ??????. . ???? 16? ????? ???? 16? ???? ??? ??? 4? ? ??? ??? ? ??, ???? 49? ???? ??? 7? ? ??? ??? ? ????.
?? ??? ?? ?? sqrt()? ???? ???? ?????.
??:
<!---program to calculate square root of input number using form -->
<html>
<head>
<title>Square root of a number using form</title>
</head>
<body>
<!--- input form with text box --->
<form method="post" action="">
<label>Enter a number</label>
<input type="text" name="input" value="" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
if(isset($_POST['submit'])) {
//storing the number in a variable $input
$input = $_POST['input'];
//storing the square root of the number in a variable $ans
$ans = sqrt($input);
//printing the result
echo 'The square root of '.$input.'====='.$ans;
}
?>
</body>
</html>
?? – 1:

?? – 2: 100? ???? ??

?? #5
??? sqrt() ??? ???? ?? ??? ??? ??:??? ??????? ??? sqrt() ??? ???? ?? ??? ???? ???? ????? PHP? ??????. sqrt() ??.
??:
function squareroot($input)
{
//if the input number is 0 then return 0 as result
if($input == 0) {
return 0;
}
//if the input number is 1 then return 1 as result
if($input == 1) {
return 1;
}
// assigning $input value to a variable $a
$a = $input;
$b = 1;
while($a > $b)
{
// calculating the middle number
$a= ($a + $b)/2;
// dividing the input number with the middle number
$b = $input/$a;
}
return $a;
}
echo '<br>'.'Square root of 0 is '.squareroot(0);
echo '<br>'.'Square root of 20 is '.squareroot(20);
echo '<br>'.'Square root of 49 is '.squareroot(49);
echo '<br>'.'Square root of 81 is '.squareroot(81);
echo '<br>'.'Square root of 1 is '.squareroot(1);
??:

??
? ??? ??? ???? ????, sqrt(), pow()? ?? ?? ??? ????? ???? ?? ???? ???? ??? ?????. sqrt() ? pow() ??? ??? ???? ?????? ???? ?? ? ??? ?????? ??? ??, ?? ??? ??, ?? ?? ?? ???? ???? ??? ?????. ??? ???? ??? ?? ???? ???? ???? ??? ?????.
? ??? PHP? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!