php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60017 __FILE__ case inconsistency on Mac / MAMP
Submitted: 2011-10-08 21:51 UTC Modified: 2021-08-01 04:22 UTC
Votes:7
Avg. Score:4.0 ± 1.4
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:4 (80.0%)
From: ykessler at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: Irrelevant OS: Mac OSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
18 + 2 = ?
Subscribe to this entry?

 
 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-08 23:39 UTC] karcieri at gmail dot com
Environment:
---------------
Zend Server version: 5.1.0

Test script:
---------------
Same as bug report

Actual result:
--------------
__FILE__ = /usr/local/zend/apache2/htdocs/Test
__DIR__ = /usr/local/zend/apache2/htdocs/Test

__FILE__ = /usr/local/zend/apache2/htdocs/Test
__DIR__ = /usr/local/zend/apache2/htdocs/Test

Is it possible that this bug is only related to the Users directory?
 [2011-10-16 13:30 UTC] ykessler at gmail dot com
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/2
 [2011-11-05 01:10 UTC] pjb109 at hotmail dot com
Trying to write to a php file but not possible on MAMP. 

Instead tried to echo the line '<?php $var = "abc"; ?>'  and this is also not possible?? Any ideas.
 [2012-01-23 22:30 UTC] gmblar+php at gmail dot com
This 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"
 [2021-07-20 11:10 UTC] cmb@php.net
-Status: Open +Status: Feedback -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: cmb
 [2021-07-20 11:10 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?  However, even if so, I wouldn't classify this as
bug, since on case-insensitive filesystem, case doesn't really
matter.  Still, it would be nice to handle that like on Windows.

[1] <https://www.php.net/supported-versions.php>
 [2021-08-01 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC