note 30522 added to reserved
| From: | php-general at lists dot php dot net | Date: | Thu, 20 Mar 2003 21:59:24 +0000 |
| Subject: | note 30522 added to reserved | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45576@lists.php.net to get a copy of this message | ||
I don't see anywhere else in the manual where this is documented, so: the __FILE__ keyword is
the filename of the current file, and __LINE__ is the line in the file. Note that this is not the
same as using some of the variables, such as $GLOBALS['PHP_SELF'], because for example:
bar.php:
<?php
echo "\n";
echo __FILE__;
echo "\n";
echo __LINE__;
?>
foo.php:
<?php
include("bar.php");
echo "\n";
echo __FILE__;
echo "\n";
echo __LINE__;
?>
executing foo.php gives me this:
/var/www/html/bar.php
5
/var/www/html/foo.php
6
Whereas if I used for example $GLOBALS['SCRIPT_FILENAME'] I would see the same filename
for both outputs... suppose I change bar.php to be
<?php
echo "\n";
echo __FILE__;
echo $GLOBALS['SCRIPT_FILENAME'];
?>
Then executing foo.php will say
/var/www/html/bar.php // <-- this line came from bar.php
/var/www/html/foo.php // <-- this line came from bar.php
/var/www/html/foo.php // <-- this line came from foo.php
6
--
http://www.php.net/manual/en/reserved.php
http://master.php.net/manage/user-notes.php?action=edit+30522
http://master.php.net/manage/user-notes.php?action=delete+30522
http://master.php.net/manage/user-notes.php?action=reject+30522