Home  >  Article  >  Backend Development  >  Some less commonly used features of PHP

Some less commonly used features of PHP

巴扎黑
巴扎黑Original
2016-11-23 13:51:57901browse

1. Variable function name, you can use string concatenation function name

function aa($str) {
echo $str;}$function = "aa";$function('Hello');// ORcall_user_func($function , $param);

2. List all functions and determine whether a function exists

get_defined_functions()function_exist()

3. Accept PUT requests, PHP REST is required

parse_str(file_get_contents('php ://input'), $put_vars);

4. Parse time from string

echo date('Y-m-d', strtotime('-1 month ago'));

5. DEBUG View Call backtrace

$backtrace = debug_backtrace();var_export($backtrace[0])die();

6. Interactive command line, command line execution PHP

php -a and php -r 'echo "hello ”;'

Please see php -h

7. Memory usage detection

memory_get_peak_usage()memory_get_usage()


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php late static bindingNext article:php late static binding