This example describes the math skills of the introductory PHP tutorial. Share to everyone for your reference, specific as follows:
demo1.php
<?php
//$a = ' 5 ';
$b = 7+ $a;
echo $b;
$a = ' a ';
$b = 7+ $a;
echo $b;
? >
demo2.php
<?php
$a = 10.0;
Is_int--Detects whether the variable is an integer
if (is_int ($a)) {
echo ' passes ';
} else{
Echo ' do not pass ';
}
? >
demo3.php
<?php
$a = 10.0;
Is_int--Detects whether the variable is an integer
if (is_int ($a)) {
echo ' passes ';
} else{
Echo ' do not pass ';
}
? >
demo4.php
<?php
//rand-produces a random integer
//echo rand (0,10);
echo Mt_rand (0,100);
echo Getrandmax ()//MAX number 32767
//echo mt_getrandmax ()//MAX 2147483647?>
demo5.php
<?php
//$i = 123456789.4454;
$b = Number_format ($i, 2);
echo $b; 123,456,789.45
$i = 12378456.456789;
$b = Number_format ($i, 2, ' # ', ' @ ');
echo $b;//12@378@456#46
?>
demo6.php
<?php
//$a =-6;
Echo ABS ($a);//Absolute value
//$b = 5.66;
echo Floor ($b),//round to take the whole
//Echo ($b);/Rounded
Echo min (1,23,456,87,45,7,54)//1 Find minimum value or minimum value in array
echo Max (1,23,456,87,45,7,54);//456 the maximum or maximum value of
echo Pi () in the array,//3.14159265359
echo pow (2,6);//64
?>
More interested in PHP related content readers can view the site topics: "PHP Mathematical Arithmetic Skills Summary", "Basic PHP Grammar Primer", "PHP operation and operator Usage Summary", "PHP object-oriented Programming Program Introduction", "PHP Network Programming Skills Summary", "PHP string ( String) Usage summary, "Getting Started with Php+mysql database operations" and "Summary of common PHP database Operations Tips"
I hope this article will help you with the PHP program design.