Professional Web Applications Themes

set_error_handler() returning false - PHP Development

On Thu, 24 Jul 2003 13:34:56 +1000, Terence <tk.listsfastmail.fm> wrote: >[url]http://au.php.net/set_error_handler[/url] >says that set_error_handler() will return false if there is an error >running it. > >This has happened in my case. > >Does anyone know why this function may not work sometimes? Turn your error_reporting level up, and it will tell you. <?php set_error_handler("piglet"); ?> Outputs: Warning: set_error_handler() expects argument 1, 'piglet', to be a valid callback in /home/andyh/public_html/test.php on line 2 -- Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url]) Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])...

  1. #1

    Default Re: set_error_handler() returning false

    On Thu, 24 Jul 2003 13:34:56 +1000, Terence <tk.listsfastmail.fm> wrote:
    >[url]http://au.php.net/set_error_handler[/url]
    >says that set_error_handler() will return false if there is an error
    >running it.
    >
    >This has happened in my case.
    >
    >Does anyone know why this function may not work sometimes?
    Turn your error_reporting level up, and it will tell you.

    <?php
    set_error_handler("piglet");
    ?>

    Outputs:

    Warning: set_error_handler() expects argument 1, 'piglet', to be a valid
    callback in /home/andyh/public_html/test.php on line 2

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  2. #2

    Default Re: set_error_handler() returning false

    I think I may have been confused by the doentation which says that
    the set_error_handler() will return FALSE if there is an error.
    Obviously it returns NULL in some cases where there is _not_ an error
    and NULL !== FALSE even though NULL == FALSE

    so there was really no problem other than my perception of the behaviour.

    Thanks to you guys, I think this is cleared up for me now.

    regards.


    John van Terheijden wrote:
    >It would be nice to know some more information...
    >
    >So you use something like
    >
    >---
    >$old_error_handler = set_error_handler("myErrorHandler");
    >if (!$old_error_handler) echo "something";
    >---
    >
    >and it echoes "something"?
    >
    >I did a little test and if there wasn't a user defined error handler set
    >before, $old_error_handler will be NULL. You should test as follows:
    >
    >---
    >$old_error_handler = set_error_handler("myErrorHandler");
    >if ($old_error_handler === NULL) echo "This is the first custom error
    >handler";
    >elseif ($old_error_handler === FALSE) echo "Something went wrong";
    >---
    >
    >Note the = = = in that. I tried to
    set_error_handler("IAmNotARealFunction")
    >and set_error_handler("foo", $bar) but neither of them returned FALSE.
    >
    > - John
    >
    >----- Original Message -----
    >From: "Terence" <tk.listsfastmail.fm>
    >Newsgroups: comp.lang.php
    >Sent: Thursday, July 24, 2003 5:34 AM
    >Subject: set_error_handler() returning false
    >
    >
    >>[url]http://au.php.net/set_error_handler[/url]
    >>says that set_error_handler() will return false if there is an error
    >>running it.
    >>
    >>This has happened in my case.
    >>
    >>Does anyone know why this function may not work sometimes?
    >>I can't find any doentation for this :(
    >>
    >
    >


    Andy Hassall wrote:
    > On Thu, 24 Jul 2003 13:34:56 +1000, Terence <tk.listsfastmail.fm> wrote:
    >
    >
    >>[url]http://au.php.net/set_error_handler[/url]
    >>says that set_error_handler() will return false if there is an error
    >>running it.
    >>
    >>This has happened in my case.
    >>
    >>Does anyone know why this function may not work sometimes?
    >
    >
    > Turn your error_reporting level up, and it will tell you.
    >
    > <?php
    > set_error_handler("piglet");
    > ?>
    >
    > Outputs:
    >
    > Warning: set_error_handler() expects argument 1, 'piglet', to be a valid
    > callback in /home/andyh/public_html/test.php on line 2
    >
    > --
    > Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    > Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Terence Guest

Similar Threads

  1. #39063 [Fbk->Opn]: is_file() and file_exists() returning false on high load
    By nherdananto at gmail dot com in forum PHP Bugs
    Replies: 0
    Last Post: October 6th, 02:58 PM
  2. Replies: 0
    Last Post: October 6th, 02:40 PM
  3. #25503 [Bgs]: SQLite_query() returning NULL, not FALSE
    By o_gangrel at hotmail dot com in forum PHP Development
    Replies: 1
    Last Post: September 12th, 12:46 AM
  4. #25503 [Opn->Bgs]: SQLite_query() returning NULL, not FALSE
    By wez@php.net in forum PHP Development
    Replies: 0
    Last Post: September 12th, 12:08 AM
  5. #25503 [NEW]: SQLite_query() returning NULL, not FALSE
    By o_gangrel at hotmail dot com in forum PHP Development
    Replies: 0
    Last Post: September 11th, 11:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139