Bug #13936 Updated: Magical Constant __FILE__ contains wrong information on included files

From: Date: Mon, 05 Nov 2001 21:10:21 +0000
Subject: Bug #13936 Updated: Magical Constant __FILE__ contains wrong information on included files
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-69659@lists.php.net to get a copy of this message
ID: 13936 Updated by: jeroen Reported By: jpm@phpbrasil.com Old Status: Open Status: Bogus Bug Type: Variables related Operating System: Solaris PHP Version: 4.0.6 New Comment: You say that it doesn't work correctly, but what did you expect then, and what did PHP return? I expect: (see the manual) orig file: test.php included file: test2.php anothyer try: test2.php And indeed: [jjawolff@abeel]/tmp/php/php-4.0.6> uname -a SunOS abeel.students.cs.uu.nl 5.6 Generic_105181-26 sun4u sparc SUNW,Ultra-5_10 [jjawolff@abeel]/tmp/php/php-4.0.6> ./php ../test.php X-Powered-By: PHP/4.0.6 Content-type: text/html original file is: ../test.php<br>included file is: /tmp/php/test2.php<br>another try: /tmp/php/test2.php[jjawolff@abeel]/tmp/php/php-4.0.6> So this probably not a bug, but a misunderstanding of __FILE__ (note: __FILE__ being '../test.php' is not what i'd expect, I expected an absolute path name) Previous Comments: ------------------------------------------------------------------------ [2001-11-05 11:34:13] jpm@phpbrasil.com [jpm@mercury: Mon Nov 5 11:27:56] [~]$ uname -a SunOS mercury 5.8 Generic_108529-10 i86pc i386 i86pc This is a very strange bug, as I have a similar piece of code running on the same server and it gives me the expected information (i.e. the full server related path for the script being run). However, this simple set of scripts gives me the wrong information: contents of test.php: <?php echo "original file is: " . __FILE__ . "<br>"; include("test2.php"); ?> contents of test2.php: <?php echo "included file is: " . __FILE__ . "<br>"; $boo = "another try: " . __FILE__; echo $boo; ?> As described above, a similar piece of code works perfectly on the same server but using a different virtual host. This similar code is actually a bunch of classes that use a specialized Error handler class to report any problems, and the error is mailed to me. On these emails, I get the correct __FILE__ output and everything works as expected. Any pointers would be very appreciated. Joao Prado Maia ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13936&edit=1

« previous php.dev (#69659) next »