Fatal Error - is this any way to not stop the script?

I have a simple script:

<?php

$source = '../path/img.jpg';
$image = imagecreatefromjpeg($source);

?>

Finally I got:

Fatal error: valid memory size 134217728 Bytes exhausted

But when I try to do something like this:

<?php

$source = '../path/img.jpg';

$image = @imagecreatefromjpeg($source); // Mute Fatal Error
if ( !$image )
{
    die('Image file is too large');
}

?>

but that will not work. Fatal error stops my script. Is there any way to change this? I would like to know when a fatal error exists (then I got FALSE as $ image), and then I would like to stop the script, but first I want to print information about it.

Thank.

0
source share
1 answer

Fatal error cannot be disconnected or caught. You should increase the amount of memory available for a PHP script using memory_limit in php.ini

-1
source

Source: https://habr.com/ru/post/1687678/


All Articles