|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-05 11:34 UTC] jpm at phpbrasil dot 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 19:00:02 2025 UTC |
Another good argument in favor of __FILE__ returning the full path is the actual purpose of this variable. People usually use __FILE__ and __LINE__ to develop routines to report problems or even events on their applications. As the manual says, one could write something like this: <?php function report_error($file, $line, $message) { echo "An error occured in $file on line $line: $message."; } report_error(__FILE__, __LINE__, "Something went wrong!"); ?> To get a report of eventual errors on some library file. Can you tell me how would I know _which_ library file or script the error occurred without __FILE__ returning me the full path of the offending script ? We could have several 'index.php' files running this 'report_error' function, and if __FILE__ returns only 'index.php', then we wouldn't know exactly which file it is. Anyway, I think it is pretty clear __FILE__ should return the full path. --Joao