PHP obtains the code of the current website and domain name
- Echo SERVER ['server _ name']; // Obtain the source URL, that is, click the previous URL on this page.
- Echo SERVER ["HTTP_REFERER"];
- SERVER ['request _ URI ']; // Obtain the suffix of the current domain name
- SERVER ['http _ host']; // Obtain the current domain name
- Dirname (_ FILE _); // Obtain the physical path of the current FILE
- Dirname (_ FILE _). "/../"; // Obtain the upper-level physical path of the current FILE
- ?>
Articles that you may be interested in: detailed explanation of how PHP retrieves domain name global variables to implement dns domain name query (text) php: PHP: how to obtain the domain name and domain name IP address php: how to obtain the domain name in the URL code example PHP: how to obtain the current website address and domain name code php regular expression matching the domain name in the url php calls the HiChina interface to implement domain name query function |