1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php on error handler

Discussion in 'PHP' started by srdva59, Jul 21, 2010.

  1. #1
    hi,
    sometimes when i run a script i receive this error:

    Fatal error: Allowed memory size i need to send a alert some like this:

    echo "<script> alert ( ' '); <script>";
    when a error is detected
    there is a error handler in php?
    something like this: on error goto x
    thanks a lot for your help
    :)
     
    srdva59, Jul 21, 2010 IP
  2. po_taka

    po_taka Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http ://www.php.net/manual/en/function.set-error-handler.php
     
    po_taka, Jul 21, 2010 IP
  3. Unlimited Power

    Unlimited Power Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Take a look at set_error_handler ;)

    ** Ah, someone beat me to it ..
     
    Unlimited Power, Jul 21, 2010 IP
  4. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #4
    Set_error_handler doesn't work with fatal errors ;-)

    I don't think it's possible to make a custom error handler for this error, although you can try somethings with sending javascript at the beginning of the file, and disabeling when loaded, but i doubt it if that will work right...
     
    ssmm987, Jul 21, 2010 IP
  5. dacash

    dacash Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would try to do try and catch statements

    like
    try{
    DoStuff();
    }catch(Exception $e){
    DoThisOnFail();
    }
     
    dacash, Jul 21, 2010 IP
  6. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #6
    I don't use try and catch statement that much, but I'm quite sure it won't work in this situation, because nothing is thrown.

    There are 2 solutions to this problem: 1.Increase the allowed memory size 2.Edit your script, so it does need less memory.
     
    ssmm987, Jul 22, 2010 IP
  7. dacash

    dacash Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah your right, the try and catch wouldn't work here. Was late last night and i just realized i was wrong. He would have to go with Edit his script to use less memory since to change the php allowed memory in php.ini would require root access to the box.
     
    dacash, Jul 22, 2010 IP