Several uncommon but particularly useful PHP predefined variables

步履不停
Release: 2023-04-06 22:20:01
Original
3070 people have browsed it

Several uncommon but particularly useful PHP predefined variables

1. $php_errormsg — Previous error message

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

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);
?>
Copy after login

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

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

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

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


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template