1

Can you help me?

<?php 

$url='http://www.amigosdoforum.com.br/wp-content/uploads/2015/02/vingas.jpg';
$contents=file_get_contents($url);
if (false == $contents) {
  echo "Error!!";
} else {
  file_put_contents($_SERVER["DOCUMENT_ROOT"]."/system/images/aaa.jpg",$contents);
  echo "Success";
}

?>

This code is not catching "Fatal error: Maximum execution time of 30 seconds exceeded".

I know that I'm able to change the limit, but I don't want it! I just want to catch this error and show to me if the code downloaded the image or not

What should I do?

spycode
  • 23
  • 8

1 Answers1

0

You cannot catch it because it's not an exception. You can register the shutdown function to handle this:

<?php
register_shutdown_function('shutdown');

function shutdown()
{
      // Your code to handle when PHP is down

}
Vũ Nhật Anh
  • 512
  • 5
  • 14