php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15793 inconsistent behaviour for __FILE__ constant
Submitted: 2002-02-28 16:00 UTC Modified: 2002-09-29 20:23 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:5 (83.3%)
From: jas at cs dot yorku dot ca Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.1.2 OS: Solaris 8
Private report: No CVE-ID: None
 [2002-02-28 16:00 UTC] jas at cs dot yorku dot ca
__FILE__ constant behaviour in PHP seems to have some problems that are Solaris specific, and some problems that are just general.

Put the following in a file "test.php":

<?php
echo "file " . __FILE__;
?>

Try:
php test.php

The expected result is:
file <path to test.php>/test.php

The result on both Linux and Solaris PHP is:
file test.php

Now call the same php script VIA the web.  The result will be the expected "file <path to test.php>/test.php" on both Linux and Solaris.  If this isn't a bug, it seems like maybe an inconsistency in PHP behaviour under different operating modes.

However, the problems continue.

Change the original test.php script above to:

<?php
echo "file " . __FILE__ . " ";
require_once './tmp/test1.php';
?>

And in tmp/test1.php put the following:
<?php
echo "file " . __FILE__;
?>

Access test.php VIA the web.

I expect to see:
file /cs/home/jas/www//test.php file /cs/home/jas/www/tmp/test1.php

On Linux that's what you'll see.

On Solaris, I  see:
file /cs/home/jas/www/test.php file /tmp/test1.php

If I specify a full path to "tmp/test1.php" -- /cs/home/jas/www/tmp/test1.php, then the result is as expected.

What's going on with __FILE__?  Am I misunderstanding its use?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-28 17:00 UTC] pb at no_spam_please dot pebe dot net
I'm experiencing the exact same problem, and it's making horde/imp a no-go. The new horde 2.0 and imp 3.0 is using __FILE__ everywhere in the code, and due to this bug it just won't work without modifying a lot of the code.

/pb
 [2002-07-25 06:15 UTC] niels at creatype dot nl
This problem is a duplicate of:
Bug #13936 Magical Constant __FILE__ contains wrong information on included files

http://bugs.php.net/bug.php?id=13936&edit=1
 [2002-09-29 20:23 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 23:01:26 2024 UTC