Php Math

Sujitha

 Php Math

      In PHP, "math" refers to mathematical operations and functions that you can use to perform calculations.

Php pi() function

      This constant represents the ratio of a circle's circumference to its diameter.

<?php
echo(pi());
?>

 // output 3.1415926535898

Php min() and max() function

         The min() and max() functions in PHP are used to find the minimum and maximum values from a list of arguments or an array.

<?php
echo(min(0, 10, 30, 20, -6, -250) . "<br>");
echo(max(0, 10, 30, 20, -6, -250));
?>

//output -250  10


Php  abs()  function


     The abs() function in PHP is used to calculate the absolute (positive ) value of a number.

<?php
echo(abs(-4.9));
?>

// output 4.9


Php sqrt() function


        The sqrt() function in PHP is used to calculate the square root of a given number. 

<?php
echo(sqrt(16) . "<br>");
echo(sqrt(0) . "<br>");
echo(sqrt(36) . "<br>");
echo(sqrt(81));
?>

// output 4  0  6  9


Php round() function


        The round() function in PHP is used to round a floating-point number to the nearest integer.

<?php
echo(round(0.58) . "<br>");
echo(round(-4.68) );
?>

//output 1  -4






Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send