What are the different ways to retrieve a URL in PHP?

  1. Access the URL of the current page using $_SERVER[‘REQUEST_URI’].
  2. Retrieve the hostname using $_SERVER[‘HTTP_HOST’].
  3. Get query string using $_SERVER[‘QUERY_STRING’].
  4. Retrieve the referring page URL using $_SERVER[‘HTTP_REFERER’].
  5. Use $_SERVER[‘SCRIPT_NAME’] to obtain the path of the current script.
  6. Retrieve the path and filename of the current script using $_SERVER[‘PHP_SELF’].
  7. Retrieve the request method using $_SERVER[‘REQUEST_METHOD’].
  8. Check if the current protocol is HTTPS using $_SERVER[‘HTTPS’].
  9. Retrieve user agent information using $_SERVER[‘HTTP_USER_AGENT’].
  10. Get the client’s IP address by using $_SERVER[‘REMOTE_ADDR’].
Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds