Predefined variables: $ _ Server
Note: PhP 4.1.0 and later versions are used. In earlier versions, $ http_server_vars is used.
$ _ Server is an array containing headers, paths, and script locations. The object of the array is created by the Web
$ _ Server ['php _ Self '] # File Name of the script being executed, which is related to document root.$ _ Server ['argv'] # parameters passed to the script.$ _ Server ['argc '] # contains the number of command line parameters passed to the Program (
In the past, I was curious that the website could obtain the IP address of the user accessing the current page. Now I know that the website uses the $ _ server parameter $ _ server ['remote _ ADDR '] in $ _ server.
You can input parameters to the $
A1.1 Apache module
In the building blocks game, each building block has different shapes and sizes. The children select the right building blocks based on their own imagination to build a complete house. The Apache module is similar to this. Each
$ _ Server ['php _ Self '] # File Name of the script being executed, which is related to document root.$ _ Server ['argv'] # parameters passed to the script.$ _ Server ['argc '] # contains the number of command line parameters passed to the Program (
Some SERVER information is often used in PHP programming. the detailed parameters of $ _ SERVER are sorted out, you can easily use $ _ SERVER ['php _ SELF '] # file name of the script being executed, which is related to document root.
$ _ SERVER
This article provides a detailed analysis of PHP's methods for obtaining the current url. if you need a friend, refer to the following, I hope to help you. Today, we will introduce the specific methods for PHP to obtain the function of the current
Common php pre-defined variables can be added to your favorites for future use.
The code is as follows:
Echo "current operating system information". PHP_ OS ."
";
Echo 'file path and FILE name: '. _ FILE __.'
';
Echo "current PHP version
According to official documentation 5.4.0, this function can be used for FastCGI. Previously, it was only supported when PHP was running as an Apache module. However, when I call this function in Nginx + php-fpm mode, an undefined error is returned.
Copy CodeThe code is as follows:
echo "Current operating system Information". Php_os. "
";
Echo ' This file path and file name is: '. __file__. '
';
echo "Current PHP version information". Php_version. "
";
?>
Common PHP pre-defined
After the CentOS server is restarted, there is no such problem before the 403 Forbidden restart occurs on the website. for apache server, please check out the problem. if nothing else happens, restart the server.
Reply to discussion
Author: When Albert PHP runs as an Apache module, Apache itself is the dominant security, so if configured correctly, PHP should be a very secure environment, but if PHP is run in CGI mode, it is not so safe. The actions that are mentioned in this
$ _ SERVER [& amp; #39; PHP_SELF & amp; #39;] # file name of the script being executed, which is related to documentroot. $ _ SERVER [& amp; #39; argv & amp; #39;] # parameters passed to the script. $ _ SERVER [& amp; #39; argc & amp; #39;] #
What we are introducing to you today is a concrete way to get the function of the current URL of PHP, through the understanding of this function method, further deepen our understanding of the PHP language, improve our learning level.
Examples of
[page]$_server[' php_self '] #当前正在执行脚本的文件名, related to document root.
$_server[' argv '] #传递给该脚本的参数.
$_server[' argc '] #包含传递给程序的命令行参数的个数 (if run in command-line mode).
$_server[' Gateway_interface ') #服务器使用的 the version of the CGI specification.
I. What is FastCGI?FastCGI is a CGI open extension in a language-independent and scalable architecture. Its main behavior is to maintain the CGI interpreter process in the memory and thus achieve high performance. As we all know, repeated loading
$ _ Server ['php _ Self '] # File Name of the script being executed, which is related to document root.$ _ Server ['argv'] # parameters passed to the script.$ _ Server ['argc '] # contains the number of command line parameters passed to the Program (
Four Common php running methods
This article mainly introduces four common php running methods. This article describes CGI, FastCGI, APACHE2HANDLER, CLI, and other four running methods. For more information, see
SAPI: Server Application Programming
[PHP] predefined variable (1) $ _ server (Appendix: getting the current URL example)
For example, I need to obtain the current URL address.
$ Url_this ="Http: // ". $ _ Server['HTTP _ host']. $ _ server ['php _ Self '];Echo $ url_this;
Readers who frequently access the Internet may encounter this situation: when accessing some resources of some websites, a dialog box pops up in the browser asking users and passwords to access resources. This is a technology used for user
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.