Php function code for getting website addresses

Source: Internet
Author: User
Php function code for getting website addresses

  1. /**

  2. * Obtain the complete website address.
  3. * By bbs.it-home.org
  4. */
  5. Function getRootUrl (){
  6. $ Name = '';
  7. If (isset ($ _ SERVER ['http _ host']) {
  8. $ Name = $ _ SERVER ['http _ host'];
  9. } Else {
  10. $ Name = $ _ SERVER ['server _ name'];
  11. }
  12. If (strpos ($ name, ':') ===false & $ _ SERVER ['server _ port']! = 80 ){
  13. $ Name. = ':'. $ _ SERVER ['server _ port'];
  14. }
  15. $ Path = $ _ SERVER ['php _ SELF '];
  16. $ Path = substr ($ path, 0, strrpos ($ path, '/') + 1 );

  17. Return 'http: // '. $ name. $ path;

  18. }

>>> Extended reading: PHP obtains visitors' IP addresses in two ways. PHP obtains MAC addresses. implementation code: php obtains the final address of a youku video. example of php obtaining a real IP address: PHP: How to Get domain name and domain name IP address php: how to get the redirected URL address instance code php: how to get the client IP address php: how to get the computer MAC address example php: how to hide the real instance code of the file php obtains the local Lan (intranet) IP address code and function description: six methods to obtain the IP address of the php Client php code to obtain the real IP address of the User php code to achieve IP address and digit interchange php code to obtain the Nic MAC address and URL in the main domain code php: php code used to determine whether the IP address is a domestic IP address or a foreign IP address. php code used to obtain the client IP address, geographical information, browser information, and local real IP address. php code used to capture the email address on the webpage. php code used to record the visitor's IP address. default http string method for URL address php verification email address function php obtains client IP address four methods use php to get user IPv4 or IPv6 address code

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.