Home >Backend Development >PHP Tutorial >Several uncommon but particularly useful PHP predefined variables

Several uncommon but particularly useful PHP predefined variables

步履不停
步履不停Original
2019-06-25 14:16:493103browse

Several uncommon but particularly useful PHP predefined variables

1. $php_errormsg — Previous error message

<?php
@strpos();
echo $php_errormsg;
?>

2. $http_response_header — HTTP response header

<?php
function get_contents() {
  file_get_contents("http://example.com");
  var_dump($http_response_header);
}
get_contents();
var_dump($http_response_header);
?>

3. $argc — Passed to Number of parameters of the script

<?php
var_dump($argc);
?>
当使用这个命令执行: php script.php arg1 arg2 arg3

4. $argv — Array of parameters passed to the script

<?php
var_dump($argv);
?>
当使用这个命令执行:php script.php arg1 arg2 arg3


For more PHP related technical articles, please visit the PHP Tutorial column to learn!

The above is the detailed content of Several uncommon but particularly useful PHP predefined variables. For more information, please follow other related articles on the PHP Chinese website!

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