How To Use PHP Maths Function Example ?
Teams applying “How To Use PHP Maths Function Example ?” in a production project can use visit this page to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.
Before copying the example into a live application, confirm version-specific behaviour with the PHP project and test it against the project’s actual database and runtime.
Hi guys,
Today i will explained how to use php Maths function in your php file. This example is so easy to use in php. This example to i am use in many Maths function in php file.
THe maths function is provided in a php in by default. Maths function use to vary easy here.
This example to i am use in pi(),min(),max(),abs(),sqrt(),round(),rand() function used in this tutorial. So you are follow for my step by step.
So let's start to the example.
Pi() Function Example
Pi() function is return to the pi value.
<?php
echo(pi());
echo "<br>";
// returns 3.1415926535898
?>
Output
3.1415926535898
Min() and Max() Function Example
Min() and Max() function is return to the minimun and maximum value return in the list
<?php
echo(min(0, 150, 30, 20, -8, -200));
echo "<br>";
// returns -200
echo(max(0, 150, 30, 20, -8, -200));
echo "<br>";
// returns 150
?>
Output
Min : -200
Max : -200
Abs() Function Example
Abs() function is only return to the absolute(positive) value return.
<?php
echo(abs(-6.7));
echo "<br>";
// returns 6.7
?>
Output
6.7
Sqrt() Function Example
Sqrt() function is return the square root of a number.
<?php
echo(sqrt(64));
echo "<br>";
// returns 8
?>
Output
8
Round() Function Example
Round() function is return the floating-point to nearest integer.
<?php
echo(round(0.60));
echo "<br>";
// returns 1
echo(round(0.49));
echo "<br>";
// returns 0
?>
Output
Round :1
Round :0
Rand() Function Example
Rand() function generates a random number and you are defind to minimum and maximum value defined then number generates in your number.
<?php
echo(rand());
echo "<br>";
// return 585927897
echo(rand(10, 100));
echo "<br>";
// return 10
?>
Output
Rand :585927897
Rand :10
Now you can check your own.
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example