php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51312 include_once/require_once are case sensitive on OS X
Submitted: 2010-03-17 05:36 UTC Modified: 2013-06-25 15:02 UTC
From: whatthejeff at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.2 OS: Mac OS X 10.6
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: whatthejeff at gmail dot com
New email:
PHP Version: OS:

 

 [2010-03-17 05:36 UTC] whatthejeff at gmail dot com
Description:
------------
With PHP 5.3.2 on OS X 10.6 I am able to include the same file multiple times using include_once() and require_once()

Configurations:
--
$ /usr/local/php-test/bin/php -v
PHP 5.3.2 (cli) (built: Mar 16 2010 21:48:40) 

$ /usr/local/php-test/bin/php -i | grep config
Configure Command =>  './configure'  '--prefix=/usr/local/php-test'



Test script:
---------------
$ echo '<?php echo "included\n"; ?>' > test.php
$ php -r 'require_once("test.php"); require_once("Test.php");'

or

$ php -r 'include_once("test.php"); include_once("Test.php");'

Expected result:
----------------
included

Actual result:
--------------
included
included

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-19 06:09 UTC] whatthejeff at gmail dot com
-Summary: Case-insensitive include_once/require_once includes file more than once +Summary: include_once/require_once are case sensitive on OS X
 [2010-03-19 06:09 UTC] whatthejeff at gmail dot com
Further testing indicates that this bug does not exist for all case sensitive file systems.  I could not reproduce this error using Windows.
 [2010-06-08 14:44 UTC] tony2001@php.net
-Status: Open +Status: Bogus
 [2010-06-08 14:44 UTC] tony2001@php.net
It's not reproducible on windows because filesystems there are ALWAYS case insensitive. But since on Mac it's possible to choose between case sensitive and case insensitive FS, you have to control this yourself - there is no way for PHP to 'detect' how exactly the filename should be used (and even if there is, it would mean a nice performance impact).
In short - this is not PHP problem.
 [2010-06-08 17:36 UTC] whatthejeff at gmail dot com
Just to be clear, you don't think this is something that could be detected or specified at compile time?  I have scripts that have worked across all major platforms for years that suddenly don't work for OS X and your proposed solution is that if people want require_once to work as expected on OS X they have to manage it themselves?
 [2010-06-08 17:41 UTC] aharvey@php.net
I can't see any logical way of doing this at compile time: individual file systems within Mac OS X (and, indeed, other non-Windows platforms) can be case sensitive or insensitive, so while you could theoretically warn about case sensitive file systems being mounted during compilation, there's no advantage, since that doesn't guarantee what file systems will be mounted later. (Plus, plenty of people compile PHP on one system to use on many, which may themselves have different configurations.)

Bottom line: PHP is case sensitive when the underlying file system is case sensitive. That's not a bug.
 [2010-06-08 18:07 UTC] whatthejeff at gmail dot com
Alright, no one is saying that's the bug.  The bug is that I can include the same file multiple times with require_once.  I see what you're saying about mounting different file systems though.  I understand if there's no logical solution but maybe a warning could be added to the docs so that people are aware of this issue.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 17 06:01:26 2025 UTC