Sun 4 Oct 2009
PHP in Windows, under IIS and Apache, file path is handled differently
Posted by luar under PHPNo Comments
PHP in Windows, under IIS and Apache, file path is handled differently, for example:
echo $_SERVER["SCRIPT_FILENAME"];
?>
Under IIS:
C:\Projects\test.php
Under Apache:
C:/Projects/test.php
So if you want based on “/” to do something like RegEx, remember convert Windows style file path to Unix style, e.g:
$filename = str_replace('\\', '/', $_SERVER["SCRIPT_FILENAME"]);
?>
Then your PHP will run cross platform either in Windows IIS or Apache, or Linux.
