Page 1 of 1

Finding Page Path

Posted: Fri Feb 25, 2005 5:35 pm
by Smartweb
How would I go about getting the file and directory (or in other words full path) of the file that's being executing into a variable?

Posted: Fri Feb 25, 2005 5:39 pm
by s.dot
If you're talking about the page that's being executed right now it'd look like this.

Code: Select all

$path = $_SERVERї'PHP_SELF'] . (!empty($_SERVERї'QUERY_STRING']) ? '?' . $_SERVERї'QUERY_STRING'] : '');
I just recently asked a question similar to this and that code to find the full path, including the page and query string was shown to me by Feyd. :). He knows alot.

Posted: Fri Feb 25, 2005 5:41 pm
by smpdawg
Or $_SERVER['SCRIPT_FILENAME'] to get the path to the script relative to the file system.

Posted: Fri Feb 25, 2005 5:45 pm
by Smartweb
Yeah, thanks, that's exactly what I wanted. :)