Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/02/2012, 13:50
mich022
 
Fecha de Ingreso: mayo-2011
Mensajes: 10
Antigüedad: 13 años
Puntos: 3
Respuesta: Validar memory_limit

Cita:
Iniciado por andresdzphp Ver Mensaje
En caso de que el script se detenga de esa manera puedes buscar si el último error es Allowed memory size y hacer algo usando la función [URL="http://www.php.net/manual/es/function.register-shutdown-function.php"]register_shutdown_function[/URL], pero como es fatal no se puede capturar con una excepción.

Código PHP:
Ver original
  1. <?php
  2.  
  3. function () {
  4.     $error = error_get_last();
  5.     if (strstr($error['message'], 'Allowed memory size')) {
  6.         echo $error['message'];
  7.       //hago algo...
  8.     }
  9. });
  10.  
  11. //Genera el error Fatal error: Allowed memory size
  12.  
  13. while (true) {
  14.     $data .= str_repeat('#', PHP_INT_MAX);
  15. }
Ingeniosa solución. No conocia esa función. Muchisimas Gracias!