note 78480 deleted from reserved.variables by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:28:21 +0000 |
| Subject: | note 78480 deleted from reserved.variables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134371@lists.php.net to get a copy of this message | ||
Note Submitter: doheth.co.uk
----
slight improvement to the example by 'andres at andresj dot ath dot cx' for determining
the path to the currently script.
Previous version:
<?php
// If your script is included from another script:
$included_directory = substr(__FILE__, 0, strrpos(__FILE__, '/'));
?>
Windows uses back-slash to indicate folders, so this didn't work on localhost for me. All you
need to do is convert any back-slashes to forward-slashes. This should work on all systems:
<?php
// If your script is included from another script:
$included_file = str_replace('\\', '/', __FILE__);
$included_directory = substr($included_file, 0, strrpos($included_file, '/'));
?>