|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-05-04 00:27 UTC] lodder at yacc dot com dot au
[2002-09-28 17:11 UTC] iliaa@php.net
[2002-10-14 19:26 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
Summary: when using include, __FILE__ prepends / to relative paths History: Received errors from imp3.0 saying could not find included file. Error message reported strange path names. See Horde bugs #911 and #912. Sample Code: a.php => <?php echo "Calling file ", __FILE__; echo "<br>included as lib/a.php reports "; include 'lib/a.php'; echo "<br>included as ./lib/a.php reports "; include './lib/a.php'; echo "<br>included as /www/yacc/tmp/lib/a.php reports "; include '/www/yacc/tmp/lib/a.php'; ?> lib/a.php => <?php echo __FILE__; ?> When I do this, I get Calling file /www/yacc/tmp/a.php included as lib/a.php reports /lib/a.php included as ./lib/a.php reports /lib/a.php included as /www/yacc/tmp/lib/a.php reports /www/yacc/tmp/lib/a.php Something keeps putting a leading / on relative paths! Other Tests: I created a simple C program to print out the __FILE__ value. When is compile it with HP's ANSI C compiler it works as expected i.e. the value is as specified in the include. When I compile with GNU CC compiler (gcc) the value is "sanitised". See below /home/gedl/tmp $ cc -o a a.c ./lib/b.c && echo "The output" && ./a a.c: ./lib/b.c: The output a.c ./lib/b.c /home/gedl/tmp $ gcc -o a a.c ./lib/b.c && echo "The output" && ./a The output a.c lib/b.c /home/gedl/tmp $ Essentially the same but not exactly. However both compilers give a valid answer. I will continue to work on it but if someone has an answer it would be appreciated. Cheers Ged