|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-10-08 21:51 UTC] ykessler at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/language.constants.predefined --- __FILE__ and __DIR__, return lower case paths when in the calling file, and mixed case paths in an included file, when run on MAMP. Test script: --------------- //The following will show all lower case paths when in the calling file, //and mixed case paths in an included file, when run on MAMP. echo "<br/>__FILE__ = ".__FILE__; echo "<br/>__DIR__ = ".__DIR__; // include another file with the same code ... Actual result: -------------- __FILE__ = /users/me/stuff/mamp_server/my_site/myfile.php __DIR__ = /users/me/stuff/mamp_server/my_site __FILE__ = /Users/me/Stuff/mamp_server/my_site/myfile.php __DIR__ = /Users/me/Stuff/mamp_server/my_site PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 23:00:02 2025 UTC |
Here is another test run outside the Users directory, in the standard MAMP install under Applications/MAMP/htdocs: a.php: <?php echo "<br/>__FILE__ = ".__FILE__; echo "<br/>__DIR__ = ".__DIR__; include("a_inc.php"); ?> a_inc.php: <?php echo "<br/>__FILE__ = ".__FILE__; echo "<br/>__DIR__ = ".__DIR__; ?> http://localhost/tests/a.php = __FILE__ = /applications/mamp/htdocs/tests/a.php __DIR__ = /applications/mamp/htdocs/tests __FILE__ = /Applications/MAMP/htdocs/tests/a_inc.php __DIR__ = /Applications/MAMP/htdocs/tests Zend Engine v2.3.0 OSX 10.6.8 Apache/2.0.63 (Unix) PHP/5.3.2 DAV/2This happens because the default filesystem (hfs+) is case insensitive. a.php <?php include strtolower(realpath('b.php')); include strtoupper(realpath('b.php')); b.php <?php var_dump(__FILE__); Output: string(23) "/users/blar/sites/b.php" string(23) "/USERS/BLAR/SITES/B.PHP"