Re: require_once and E_WARNING?

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

 



On Wed, 5 Jul 2006, php@xxxxxxxxxxxxxxx wrote:

Hello all,

According to the PHP Manual, when require or require_once failes, an
E_ERROR is triggered: "require() and include()  are identical in every way
except how they handle failure. include() produces a Warning while
require() results in a  Fatal Error." (With 'Fatal Error' being a link to
E_ERROR).

Thing is, when using a custom error handler via set_error_handler(), it
appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
under Linux.

There are one of three possibilities: I am suffering from a lapse in
lucidity (common), the manual is wrong (possible), or PHP is broken
somehow (unlikely). I'm guessing it's the first, but what am I doing
wrong? I'd like to get a second opinion before submitting a bug. I
searched bugs.php.net but was unable to find anything relevant for 5.1.4.

Code:
function default_error_handler($code, $error, $file, $line) {
  switch ($code) {
  case E_ERROR:
     die ("Error: $error");
  case E_WARNING:
     die("Warning: $error");
  default:
     die("Something else entirely: $error");
  }
}

What happens if you put breaks after the die()? This shouldn't be necesary, but it wouldn't hurt to try. ;-)

As I see in the example of the PHP manual, a break is put even after an exit(1) call.

set_error_handler('default_error_handler');
require('This file does not exist. At least not here!');

Have you tried this handler with something more fatal, like a missing semi-colon or a } missmatch?

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués         |   SELECT 'mmarques' ||
Centro de Telemática        |       '@' || 'unl.edu.ar';
Universidad Nacional        |   DBA, Programador,
    del Litoral             |   Administrador
---------------------------------------------------------
-- 
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