note 96666 deleted from function.get-included-files by danbrown
| From: | danbrown@php.net | Date: | Wed, 10 Mar 2010 17:58:25 +0000 |
| Subject: | note 96666 deleted from function.get-included-files by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166867@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
in reply to: keystorm :at: gmail dotcom
This is quite useful to detect is current script was included or if it is that got called in the
first place. But there is one gotcha:
If you run the script via CLI, $_SERVER['SCRIPT_FILENAME'] can be the relative path to the
called script. In this case, simply comparing __FILE__ to it won't work.
to be sure that the comparison works, you should use the following:
__FILE__ != realpath( $_SERVER['SCRIPT_FILENAME'] )