php -- 数学函数

时间:2022-02-03 11:49:25

----- 016-math.php -----

 <!DOCTYPE html>
 <html>
 <head>
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
     <title>数学函数测试</title>
 </head>
 <body>
 <h3>数学函数测试</h3>
 <pre>
 <?php
     echo "-2.7的绝对值:", abs(-2.7), "\n";
     echo "2.4取FLOOR:", floor(2.4), "\n";
     echo "2.4取ROUND:", round(2.4), "\n";
     echo "2.4取CEIL:", ceil(2.4), "\n";
     echo "1023换二进制:", decbin(1023), "\n";
     echo "1和0.9哪个大:", max(1, 0.9), "\n";
     echo "2的30次方:", pow(2, 30), "\n";
     echo "1到2随机数10次:\n";
     for($i=0; $i<10; $i++)
         echo rand(1, 2), "\t\n";
     echo "取2的开方:", sqrt(2), "\n";
 ?>
 </pre>
 </body>
 </html>

php -- 数学函数