PHP的问题包括区分大小写的文件系统

Sou*_*rav 3 php

我已经在Windows中构建了一个PHP项目,正如您在Windows中所知,fun.php和Fun.php是相同的但不是在Linux中.
Q1->因为我的项目将在Linux中运行如何解决此问题[文件名错误]?
Q2->如果确切的文件名不存在,我需要显示错误!怎么办?

我有2个PHP文件template.phprender.php
代码render.php

include 'Template.php';
Run Code Online (Sandbox Code Playgroud)

我想得到一个警告,所以我可以解决这个问题[这不会在Windows中产生问题,但在Linux中]

cwa*_*ole 5

好吧,如果我在那种情况下,我会写一个包装器包括:

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;
}
Run Code Online (Sandbox Code Playgroud)

我没有机会测试它,但是SplFileInfo从操作系统获取路径名,这意味着它应该在Windows中具有正确的区分大小写.