php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63617 Make file_exists() case insensitive
Submitted: 2012-11-27 04:14 UTC Modified: 2012-11-27 05:09 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: soapergem at gmail dot com Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: Irrelevant OS: *nix
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-11-27 04:14 UTC] soapergem at gmail dot com
Description:
------------
Currently file_exists() is case insensitive on Windows, but not on *nix platforms. 
This makes it difficult to migrate from Windows back to *nix. Forcing 
file_exists() to always be case insensitive would be of great benefit in these 
scenarios. I'm not sure what the engineering behind it would involve, but I 
thought I'd ask!

Test script:
---------------
<?php

$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
var_dump(file_exists($dir . 'cAsE_mAtTeRs.php'));

?>

Expected result:
----------------
true

Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-27 05:09 UTC] aharvey@php.net
PHP relies on the underlying semantics of the file system: if the file system is case insensitive (and some file systems are or optionally can be on *nix systems — for example, HFS+ on OS X), then PHP will behave accordingly.

Having PHP behave differently to other programs on the same system would definitely violate the principle of least surprise, quite aside from the (non-trivial) amount of work required.

Closing Won't Fix.
 [2012-11-27 05:09 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Aug 24 01:01:27 2019 UTC