redd 發表於 2020-10-15 19:36:28

Math functions

pi()
<?php
echo(pi());
?>結果: 3.1415926535898

redd 發表於 2020-10-15 19:39:41

<?php
echo(min(0, 150, 30, 20, -8, -200));// returns -200
echo(max(0, 150, 30, 20, -8, -200));// returns 150
?>取最小和最大值。

redd 發表於 2020-10-15 19:51:45

<?php
echo(abs(-6.7));// returns 6.7
?>絕對值。

redd 發表於 2020-10-15 19:53:02

<?php
echo(sqrt(64));// returns 8
?>開根號。

redd 發表於 2020-10-15 19:55:16

<?php
echo(round(0.60));// returns 1
echo(round(0.49));// returns 0
?>四捨五入。

redd 發表於 2020-10-15 20:00:55

亂數
<?php
echo(rand(10, 100));
?>亂數的結果會出現 100, 不會出現 10.
頁: [1]
查看完整版本: Math functions