您好,欢迎访问一九零五行业门户网

PHP 的一些不太常用的特性

1. 变量函数名,可以用字符串拼接函数名
function aa($str) {
 echo $str;}$function = aa;$function('hello');// orcall_user_func($function, $param);
2. 列出所有函数,判断某个函数是否存在
get_defined_functions()function_exist()
3. 接受 put 请求,php rest 必备
parse_str(file_get_contents('php://input'), $put_vars);
4. 从字符串解析时间
echo date('y-m-d', strtotime('-1 month ago'));
5. debug 查看调用 backtrace
$backtrace = debug_backtrace();var_export($backtrace[0])die();
6. 交互式命令行,命令行执行 php
php -a 和 php -r ‘echo “hello”;’
更多请看 php -h
7. 内存使用检测
memory_get_peak_usage()memory_get_usage()
其它类似信息

推荐信息