In my script, I have the following lines:
$test = @imagecreatefrompng($name);
if ($test) { ... }
I am sure it $nameis an existing file on disk, but I must handle cases where this file is not a valid PNG file (due to a transmission error or due to a malicious user). I want to deal with such cases without doing anything.
However, given the code above, my PHP interpreter stops at the first line with the following error message:
imagecreatefrompng () [function.imagecreatefrompng]: 'foobar.png' is not a valid PNG file
Shouldn't @'suppress this error message and return the function falseas described in the documentation? How can I tell PHP that I know that an error may occur and not interrupt execution?
source
share