note 74159 added to function.file-exists
| From: | stephen dot reay at mac dot com | Date: | Wed, 28 Mar 2007 03:28:36 +0000 |
| Subject: | note 74159 added to function.file-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124864@lists.php.net to get a copy of this message | ||
developing a CMS, with a link checker, it caused issues that when running on Win32, file_exists
shows no error for case differences between the file on disk and the file you query for. this causes
an issue when putting content created on the Win32 box onto a *NIX box.
the following is a function to test for files with case sensitivity, regardless of the OS. it
returns 1 for a match, 0 for fails, and 2 if the file exists but with a different case.
function file_exists_case($strUrl)
{
$realPath = str_replace('\\','/',realpath($strUrl));
if(file_exists($strUrl) && $realPath == $strUrl)
{
return 1; //File exists, with correct case
}
elseif(file_exists($realPath))
{
return 2; //File exists, but wrong case
}
else
{
return 0; //File does not exist
}
}
----
Server IP: 203.16.234.91
Probable Submitter: 152.91.9.228 (proxied: unknown)
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit -- https://master.php.net/note/edit/74159
Del: integrated -- https://master.php.net/note/delete/74159/integrated
Del: useless -- https://master.php.net/note/delete/74159/useless
Del: bad code -- https://master.php.net/note/delete/74159/bad+code
Del: spam -- https://master.php.net/note/delete/74159/spam
Del: non-english -- https://master.php.net/note/delete/74159/non-english
Del: in docs -- https://master.php.net/note/delete/74159/in+docs
Del: other reasons-- https://master.php.net/note/delete/74159
Reject -- https://master.php.net/note/reject/74159
Search -- https://master.php.net/manage/user-notes.php