Fatal Error Handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I have a set of functions which are potentially dangerous in terms of memory hogging, and need to protect from memory overflow - this is I want to detect when the memory overflow occurs.


The manual says that eval() will return false on a fatal error, so I thought I could do something like the following, where it would produce a "O" for each itteration, and when it failed (memory overflow) it would continue and echo the last line. What I get however is this attached to the end.

Any advice would be gratefully recieved (and perhaps, the documentation on eval updating if it can not catch all fatal errors)

#! /usr/bin/php
<?php
 $y = 0;
 $str = "";
 $code = '$str .= $str . "."; return true;';
 $x = TRUE;
 while($x != FALSE){
  $x = eval($code);
  echo "O";
  $y ++;
 }
  echo "\n $y it's \n\n ". $str;
?>

run:
$ ./intellirun2.php
OOOOOOOOOOOOOOOOOOOOOO
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4194305 bytes) in /home/jt/work2/sms/web/stats/intellirun2.php(8) : eval()'d code on line 1


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux