[PHP] parse errors not displayed (2nd time I ask!)

2002-04-29 Thread Pedro Garre

*This message was transferred with a trial version of CommuniGate(tm) Pro*
Hi,

I am sorry I ask this for a second time. 
Come on guys ! I am sure somebody can help, please 

I set my own error handler. It is in a file general_includes.php
(please find it below) and all pages do a require on it.
It works Ok with the exception of parse errors. They are not trapped by
my error handler (which I know it's the expected behaivor) but they
don't either show up in the browser.

My php.ini file has:
display_errors = On
error_reporting = E_ALL  E_NOTICE

And general_includes.php is:
?php

// Esto se ejecutara en todos los ficheros que incluyan a este fichero
error_reporting( E_ALL ^ E_NOTICE );
$old_error_handler = set_error_handler(userErrorHandler);

function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
{
  $dt = date(d-m-Y H:i:s);

  // Paso del path
  $filename = basename ( $filename );

  // Define an assoc array of error string. In reality the only entries
we should 
  // consider are 2,8,256,512 and 1024
  $errortype = array (
  1   =  Error,
  2   =  Warning,
  4   =  Parsing Error,
  8   =  Notice,
  16  =  Core Error,
  32  =  Core Warning,
  64  =  Compile Error,
  128 =  Compile Warning,
  256 =  User Error,
  512 =  User Warning,
  1024=  User Notice
  );

  // Errors for which execution can go on.
  $errores_suaves = array(E_WARNING, E_NOTICE, E_USER_NOTICE);

  $err = errorentry\n;
  $err .= \tdatetime.$dt./datetime\n;
  $err .= \terrornum.$errno./errornum\n;
  $err .= \terrortype.$errortype[$errno]./errortype\n;
  $err .= \terrormsg.$errmsg./errormsg\n;
  $err .= \tscriptname.$filename./scriptname\n;
  $err .= \tscriptlinenum.$linenum./scriptlinenum\n;

  $err .= /errorentry\n\n;

  // For testing. NOTICE errors do not disturb the browser but are
immediatly shown
  // to the programmer. Remaining errors are displayed in the browser.
  if ( ( $errno == E_USER_NOTICE ) || ( $errno == E_NOTICE ) )
system (echo $errno $errortype[$errno] $errmsg $filename $linenum 
| write pedro pts/0 );
  else
echo br=br$err brbr;

  // My own log method, which eventualy sends an email
  logea ( C_ERROR_DEL_HANDLER, 0, $filename, $err );

  // Stop processing if serious error
  if ( ! in_array($errno, $errores_suaves) )
die(Error Interno. Por favor pruebe más tarde);
 }
?

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




Re: [PHP] parse errors not displayed (2nd time I ask!)

2002-04-29 Thread 1LT John W. Holmes

Just fix your parse errors. Who cares what error handler it goes to.

Are you going to release code with parse errors in it and do you really want
to get an email each time someone gets one?

---John Holmes...

- Original Message -
From: Pedro Garre [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Monday, April 29, 2002 5:37 PM
Subject: [PHP] parse errors not displayed (2nd time I ask!)


 *This message was transferred with a trial version of CommuniGate(tm) Pro*
 Hi,

 I am sorry I ask this for a second time.
 Come on guys ! I am sure somebody can help, please 

 I set my own error handler. It is in a file general_includes.php
 (please find it below) and all pages do a require on it.
 It works Ok with the exception of parse errors. They are not trapped by
 my error handler (which I know it's the expected behaivor) but they
 don't either show up in the browser.

 My php.ini file has:
 display_errors = On
 error_reporting = E_ALL  E_NOTICE

 And general_includes.php is:
 ?php

 // Esto se ejecutara en todos los ficheros que incluyan a este fichero
 error_reporting( E_ALL ^ E_NOTICE );
 $old_error_handler = set_error_handler(userErrorHandler);

 function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
 {
   $dt = date(d-m-Y H:i:s);

   // Paso del path
   $filename = basename ( $filename );

   // Define an assoc array of error string. In reality the only entries
 we should
   // consider are 2,8,256,512 and 1024
   $errortype = array (
   1   =  Error,
   2   =  Warning,
   4   =  Parsing Error,
   8   =  Notice,
   16  =  Core Error,
   32  =  Core Warning,
   64  =  Compile Error,
   128 =  Compile Warning,
   256 =  User Error,
   512 =  User Warning,
   1024=  User Notice
   );

   // Errors for which execution can go on.
   $errores_suaves = array(E_WARNING, E_NOTICE, E_USER_NOTICE);

   $err = errorentry\n;
   $err .= \tdatetime.$dt./datetime\n;
   $err .= \terrornum.$errno./errornum\n;
   $err .= \terrortype.$errortype[$errno]./errortype\n;
   $err .= \terrormsg.$errmsg./errormsg\n;
   $err .= \tscriptname.$filename./scriptname\n;
   $err .= \tscriptlinenum.$linenum./scriptlinenum\n;

   $err .= /errorentry\n\n;

   // For testing. NOTICE errors do not disturb the browser but are
 immediatly shown
   // to the programmer. Remaining errors are displayed in the browser.
   if ( ( $errno == E_USER_NOTICE ) || ( $errno == E_NOTICE ) )
 system (echo $errno $errortype[$errno] $errmsg $filename $linenum
 | write pedro pts/0 );
   else
 echo br=br$err brbr;

   // My own log method, which eventualy sends an email
   logea ( C_ERROR_DEL_HANDLER, 0, $filename, $err );

   // Stop processing if serious error
   if ( ! in_array($errno, $errores_suaves) )
 die(Error Interno. Por favor pruebe más tarde);
  }
 ?

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



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