亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP constants and variables environment variables

Environment variables We mainly use two environment variables, $_SERVER and $_ENV.

However, $_ENV is gradually abandoned by new versions of PHP.

[Key Points] Know where to check the name (key) and value (value) of environment variables, and remember and write down several commonly used environment variables.

Check the environment variables. We learned this on the first day of learning PHP:

<?php

phpinfo();

?>

In fact, environment variables are not something that you need to memorize. I know where to find the key of the environment variable. Just sum the value.
We learned phpinfo(); and printed out a bunch of messy things. Let’s learn about the environment variables part of it today.

In the URL where you execute phpinfo();, pull down the page and turn the page to see if you can find the part in the screenshot:

2015-08-02_55bdbf7ec59b9.png

_SERVER['middle value'], we need to understand the meaning.

If we need to display where the phpinfo(); page file we are currently accessing is located, we can execute:

<?php
//我在上圖左側(cè)找到的一項(xiàng),在前面加上了一個(gè)$(美元符),就顯示出來(lái)了當(dāng)前文件的路徑
echo $_SERVER['SCRIPT_FILENAME'];

?>

Let’s learn about the key names and values ??of some commonly used environment variables. Meaning:

Key nameMeaning
$_SERVER[ "REQUEST_METHOD"]Method to request the current PHP page
$_SERVER["REQUEST_URI"]Requested URI
$_SERVER["SERVER_SOFTWARE"]What kind of server are you using
$_SERVER["REMOTE_ADDR"]Customer’s IP address
$_SERVER["SERVER_ADDR"]Current server’s IP address
$_SERVER[ "SCRIPT_FILENAME"]The path of the main requested file
$_SERVER["HTTP_USER_AGENT"]The computer and browser currently accessing this URL Situation
$_SERVER["HTTP_REFERER"]Superior source (the address from which the user entered the current web page)
$_SERVER["REQUEST_TIME"]Current time


URI and URL are both web addresses, but URL contains the host address part, while URI does not contain the host address part, for example:
http://ipnx.cn/ abc.php?username=php The above is a URL (Uniform Resource Locator), and the URI is the part without the host and (http://)

protocol:
abc.php?username=php

time
Pronunciation: [ta?m]
Explanation: time

file
Pronunciation: [fa?l]
Explanation: file

name
Pronunciation: [ne?m]
Explanation: Name

sowftware
Pronunciation: [?s?:ftwer]
Explanation: Software

address (abbreviated addr)
Pronunciation: [??dres]
Explanation: Address

remote
Pronunciation: [r??mo?t]
Explanation: Remote, remote

server
Pronunciation: [?s?:v?(r)]
Explanation: service, server

method
Pronunciation: [?m?θ?d]
Explanation: method

port
Pronunciation: [p?:rt]
Explanation: Port


Continuing Learning
||
<?php //我在上圖左側(cè)找到的一項(xiàng),在前面加上了一個(gè)$(美元符),就顯示出來(lái)了當(dāng)前文件的路徑 echo $_SERVER['SCRIPT_FILENAME']; ?>
submitReset Code