note 72484 added to function.is-file

From: Date: Sat, 20 Jan 2007 18:10:13 +0000
Subject: note 72484 added to function.is-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-121957@lists.php.net to get a copy of this message
I just noticed that you should always test a path with is_file() before pouring it in getimagesize(), because even with the '@', getimagesize will return a fatal error on some servers (I work on french servers). so : <? // Don't $avatar = ''; if ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'].'/'.$maybewrongimagepath)) $avatar = '<img src="'.$maybewrongimagepath.'" '.$size[3].' alt="" />'; // Will return an error (notice the "@") // Use $avatar = ''; if (is_file($_SERVER['DOCUMENT_ROOT'].'/'.$maybewrongimagepath)) { if ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'].'/'.$maybewrongimagepath)) $avatar = '<img src="'.$maybewrongimagepath.'" '.$size[3].' alt="" />'; } ?> Hoping this'll help... ---- Server IP: 69.147.83.197 Probable Submitter: 90.15.180.76 ---- Manual Page -- http://www.php.net/manual/en/function.is-file.php Edit -- https://master.php.net/note/edit/72484 Del: integrated -- https://master.php.net/note/delete/72484/integrated Del: useless -- https://master.php.net/note/delete/72484/useless Del: bad code -- https://master.php.net/note/delete/72484/bad+code Del: spam -- https://master.php.net/note/delete/72484/spam Del: non-english -- https://master.php.net/note/delete/72484/non-english Del: in docs -- https://master.php.net/note/delete/72484/in+docs Del: other reasons-- https://master.php.net/note/delete/72484 Reject -- https://master.php.net/note/reject/72484 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121957) next »