一、数学函数库
● floor舍一取整(向下取整)float floor (float $value);● ceil进一取整(向上取整)float ceil(float $value);● max取最大值mixed max(mixed $value, mixed $value, ......);● min取最小值mixed min(mixed $value, mixed $value, ......);● pow幂运算number pow(number $base, number $expr);● sqrt取平方根float sqrt(float $arg)● rand产生随机数int mt_rand(int $min, int max);● 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
立即学习“PHP免费学习笔记(深入)”;
返回当前Unix时间戳
int time(void);
<?php echo time()."<br>"; $nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secs echo 'Now: '. date('Y-m-d') ."<br>"; echo 'Next Week: '. date('Y-m-d', $nextWeek) ."<br>"; ?>登录后复制
● date
格式化一个本地时间/日期
string date(string format[, int timestamp]);
● getdate
取得日期/时间信息
array getdate([int timestamp]);
<?php print_r(getdate()); ?>登录后复制MD5哈希
string md5(string $str[, bool $raw_output=false]);
strpos
返回一个字符在另一个字符第一次出现的位置
int strpos(string haystack, mixed needle[, int offset]);
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号