note 76778 added to reserved.variables
| From: | opez dot org at osu1 dot php dot net | Date: | Mon, 30 Jul 2007 15:14:33 +0000 |
| Subject: | note 76778 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129047@lists.php.net to get a copy of this message | ||
I couldn't find a better way... Here is a simple line of code that will give you the path to
the current file/script:
<?php
$path_only = implode("/", (explode('/', $_SERVER["SCRIPT_FILENAME"],
-1)));
print $path_only; // /home/worldpeace/public_html/test
print $_SERVER["SCRIPT_FILENAME"]; // /home/worldpeace/public_html/test/test.php
?>
I use this to build INCLUDE commands that call a file determined by a variable [ path + / + file ].
Dont forget the /
I hope this inspires someone.
----
Server IP: 61.195.146.164
Probable Submitter: 220.9.233.69
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit -- https://master.php.net/note/edit/76778
Del: integrated -- https://master.php.net/note/delete/76778/integrated
Del: useless -- https://master.php.net/note/delete/76778/useless
Del: bad code -- https://master.php.net/note/delete/76778/bad+code
Del: spam -- https://master.php.net/note/delete/76778/spam
Del: non-english -- https://master.php.net/note/delete/76778/non-english
Del: in docs -- https://master.php.net/note/delete/76778/in+docs
Del: other reasons-- https://master.php.net/note/delete/76778
Reject -- https://master.php.net/note/reject/76778
Search -- https://master.php.net/manage/user-notes.php