Last active
December 18, 2015 16:19
-
-
Save hx/5810427 to your computer and use it in GitHub Desktop.
When you include() a file on a case-insensitive file system, XDebug can get confused about which file you're debugging. This function converts a path with incorrect case to correct case. To test, try var_dump(fixPathCase('/uSr/BiN'));
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fixPathCase($path) { | |
if(!file_exists($path)) { | |
return false; | |
} | |
if(file_exists(strtoupper($path)) && file_exists(strtolower($path))) { | |
$parts = explode('/', $path); | |
foreach($parts as $k => $i) { | |
if($i) { | |
foreach(scandir(dirname(implode('/', array_slice($parts, 0, $k + 1)))) as $file) { | |
if(!strcasecmp($file, $i)) { | |
$parts[$k] = $file; | |
} | |
} | |
} | |
} | |
return implode('/', $parts); | |
} else { | |
return $path; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment