In the development of PHP we want to include a file The usual code is this:
Copy Code code as follows:
<?php
if (Is_file ($fileName))
Require $flleName;
Running under Windows,linux doesn't ask a question: Suppose you want to include a d:/web/webserver/a.php file now
When the value is passed, the d:/web/webserver/a.php will also include d:/web/webserver/a.php when running under Windows, because Windows is not case-sensitive and will be given an error when placed under Linux.
Is it possible to be case-sensitive when loading Windows? The code is as follows:
Copy Code code as follows:
if (Is_file ($fileName)) {
Php_os the currently running operating system
if (Strstr (Php_os, ' WIN ')) {
Realpath ($fileName) Converts the case of the file name/web/a.php if a.php does not exist and a.php returns/web/a.php
if (basename (Realpath ($fileName)) = = BaseName ($fileName))
Require $fileName;
Else
Echo ' Please check the file case ';
}else
Require $fileName;
}