一、數學函數庫
● floor
舍一取整(向下取整)
float floor (float $value);
");echo(floor(0.40)."
");echo(floor(5)."
");echo(floor(5.1)."
");echo(floor(-5.1)."
");echo(floor(-5.9)."
")?>
● ceil
進一取整(向上取整)
float ceil(float $value);
");echo(ceil(0.40)."
");echo(ceil(5)."
");echo(ceil(5.1)."
");echo(ceil(-5.1)."
");echo(ceil(-5.9)."
")?>
● max
取最大值
mixed max(mixed $value, mixed $value, ......);
");echo(max(-3,5)."
");echo(max(-3,-5)."
");echo(max(7.25,7.30)."
");?>
● min
取最小值
mixed min(mixed $value, mixed $value, ......);
");echo(min(-3,5)."
");echo(min(-3,-5)."
");echo(min(7.25,7.30)."
");?>
● pow
冪運算
number pow(number $base, number $expr);
";echo pow(6,2)."
";echo pow(-6,2)."
";echo pow(-6,-2)."
";echo pow(-6,5.5)."
";?>
● sqrt
取平方根
float sqrt(float $arg)
";echo(sqrt(1))."
";echo(sqrt(9))."
";echo(sqrt(0.64))."
";echo(sqrt(-9))."
";?>
● rand
產生隨機數
int mt_rand(int $min, int max);
";echo rand(10,100)."
";?>
● mt_rand
產生一個更好的隨機數
int mt_rand(int $min, int max);
和上面的rand用法及輸出結果類似,這個比rand快4倍。
● round
四捨五入
float round(float $val [, int $precision=0])
第二個參數可選,規定小數點保留位元
● number_format
通過千位分組格式化數字
float number_format(float $number, int $decimals=0, string $dec_point=",', string $thousands_sep=',');
二、日期時間函數庫
● time
返回當前Unix時間戳記
int time(void);
";$nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secsecho 'Now: '. date('Y-m-d') ."
";echo 'Next Week: '. date('Y-m-d', $nextWeek) ."
";?>
● date
格式化一個本地時間/日期
string date(string format[, int timestamp]);
● getdate
取得日期/時間資訊
array getdate([int timestamp]);
MD5雜湊
string md5(string $str[, bool $raw_output=false]);
strpos
返回一個字元在另一個字元第一次出現的位置
int strpos(string haystack, mixed needle[, int offset]);
http://www.bkjia.com/PHPjc/755796.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/755796.htmlTechArticle一、數學函數庫 ● floor 舍一取整(向下取整) float floor (float $value); ");echo(floor(0.40)." ");echo(floor(5)." ");echo(floor(5.1)." ");echo(floor(-5.1)." ");ec...