好吧,如果我是在那种情况下,我会写一个包装围绕包括:
function warned_include($file)
{
if(defined('DEBUG_ENV')) // define this somewhere else while in dev.
{
foreach(explode(PATH_SEPARATOR, get_include_path()) as $path)
{
// make sure the/is replaced with the OS native DIRECTORY_SEPARATOR
$fullPath = str_replace($path .DIRECTORY_SEPARATOR.$file, '/', DIRECTORY_SEPARATOR);
if(is_file($fullPath))
{
$spl = new SplFileInfo($fullPath);
if($spl->getPathname() != $fullPath)
{
echo 'case sensitivity mismatch for ' . $spl->getPathname();
}
break;
}
}
}
include $file;
}
我已经没有机会测试它,但SplFileInfo从OS,获取路径下意味着它应该在Windows中具有正确的区分大小写。
不要依赖大小写不敏感的文件名吗? –
所有这些答案都很好,但是在花时间来问这个问题并实现其中一个答案的时候,你可能只是修复了你的文件名。 –
对@ Rafe的评论...这似乎是一个坏习惯随便命名文件。如果是我(不管是谁造成的),我会清理它。修复文件名称,并传递函数/解决方法来撤销它,这无疑会创建一个新的注意事项来在这里发布问题。 :) – Dawson