PHP_SELF Function to Get Current Page URL

You may use the PHP_SELF function to the your current page url, but pay attention to what it returns below.

Here are some examples:

Here is how to print the current page URL to your screen:
echo PHP_SELF;

If your script that includes PHP_SELF is at http://jafty.com/test/self.php, it would return:
/test/self.php

Leave a Reply

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