The examples in this article describe the mathematical operation skills of PHP introductory tutorial. Share it with everyone for your reference, the details are 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 -- 检测变量是否是整数 if(is_int($a)) { echo '通过'; }else{ echo '不通过'; } ?>
Demo3.php
<?php $a = 10.0; //is_int -- 检测变量是否是整数 if(is_int($a)) { echo '通过'; }else{ echo '不通过'; } ?>
Demo4.php
<?php //rand -- 产生一个随机整数 //echo rand(0,10); //echo mt_rand(0,100); //echo getrandmax();//最大数32767 //echo mt_getrandmax();//最大数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);//绝对值 // $b = 5.66; // echo floor($b);//舍去法取整 // echo round($b);//四舍五入 echo min(1,23,456,87,45,7,54);//1 求最小值或数组中最小值 echo max(1,23,456,87,45,7,54);//456 求最大值或数组中最大值 echo pi();//3.14159265359 echo pow(2,6);//64 ?>
I hope this article will be helpful to everyone in PHP program design.
For more articles related to the summary of mathematical operation skills in PHP introductory tutorials, please pay attention to the PHP Chinese website!