note 76778 deleted from reserved.variables by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:27:50 +0000 |
| Subject: | note 76778 deleted from reserved.variables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134368@lists.php.net to get a copy of this message | ||
Note Submitter: opez.org
----
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.