PHP How to Get the Current Page URL - php database -

How to Get the Current Page URL

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

Get the Current Page URL

With the help of this tutorial page, you can see the Current Page URL.

Sometimes, you might want to get the current page URL that is shown in the browser URL window.

For example if you want to let your users submit a comment on any post, you want to get that same exact URL.

Here is how you can do that.

Add the following code to a page:

Now see the current page url using currentPageURL() function

In the given above example
Define a function named currentPageURL( ). Create a variable $PageURL with value “http”. Now, with the help of Super Global Variable $_SERVER[‘https’] checked server is secure server or not.Used Global variable $_SERVER[“SERVER_PORT”] which returns the current port of the server, Now checked if the port number is 80, it means server is local server, then displayed the server name using $_SERVER[“SERVER_NAME”] and page url using $_SERVER[“REQUEST_URI”] and assign the values inside $PageURL variable.
$PageURL variable returns the server name, server port and server url.
Call the function currentPageURL( ) to display the current page URL.

Latest Trending Technologies