note 81408 added to function.file-exists
| From: | stuart at osu1 dot php dot net | Date: | Tue, 26 Feb 2008 18:44:49 +0000 |
| Subject: | note 81408 added to function.file-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136507@lists.php.net to get a copy of this message | ||
When using file_exists, seems you cannot do:
foreach ($possibles as $poss)
{
if ( file_exists(SITE_RANGE_IMAGE_PATH .$this->range_id .'/ '.$poss
.'.jpg' )
{
// exists
}
else
{
// not found
}
}
so you must do:
foreach ($possibles as $poss)
{
$img = SITE_RANGE_IMAGE_PATH .$this->range_id .'/ '.$poss .'.jpg'
if ( file_exists($img) )
{
// exists
}
else
{
// not found
}
}
Then things will work fine.
This is at least the case on this Windows system running php 5.2.5 and apache 2.2.3
Not sure if it is down to the concatenation or the fact theres a constant in there, i'm about
to run away and test just that...
----
Server IP: 87.124.64.96
Probable Submitter: 89.213.74.139
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit -- https://master.php.net/note/edit/81408
Del: integrated -- https://master.php.net/note/delete/81408/integrated
Del: useless -- https://master.php.net/note/delete/81408/useless
Del: bad code -- https://master.php.net/note/delete/81408/bad+code
Del: spam -- https://master.php.net/note/delete/81408/spam
Del: non-english -- https://master.php.net/note/delete/81408/non-english
Del: in docs -- https://master.php.net/note/delete/81408/in+docs
Del: other reasons-- https://master.php.net/note/delete/81408
Reject -- https://master.php.net/note/reject/81408
Search -- https://master.php.net/manage/user-notes.php