How to get current page URL in PHP?To get the current page URL, PHP provides a superglobal variable $_SERVER. The $_SERVER is a built-in variable of PHP, which is used to get the current page URL. It is a superglobal variable, means it is always available in all scope. If we want the full URL of the page, then we'll need to check the protocol (or scheme name), whether it is https or http. See the example below: Output Note: The isset() function is used here to check whether HTTPS is enabled or not. It checks whether a variable exists or not.Or, we can also get the full URL of current page using another way given in the next example. Output To get only name of the current page opened at browser, see the below example: Output |
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week