php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14687 Ignoring @'s after set_error_handler() is used
Submitted: 2001-12-24 10:16 UTC Modified: 2001-12-31 05:47 UTC
From: matthew_dean at hotmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Redhat 7.0, Solaris 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matthew_dean at hotmail dot com
New email:
PHP Version: OS:

 

 [2001-12-24 10:16 UTC] matthew_dean at hotmail dot com
<?php
  function myErrorHandler($errorNum) {
    echo "$errorNum\n";
  }
  set_error_handler("myErrorHandler");
  #error_reporting (E_ALL);#doesn't change the bug behaviour
  @$j=$i;
?>

This echos: 
8


Yet according to: http://www.php.net/manual/en/function.set-error-handler.php

"Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator. "



I've tried this on 4.0.4pl1 and 4.0.6
The changelog for 4.1.0 doesn't mention a fix.

The @ works fine for lines executed before set_error_handler().



Here's one of the configure lines, though (to me) it doesn't seem likely to be a compiley issue...

'./configure' '--with-db' '--enable-dba' '--with-gdbm' '--with-xml' '--with-oci8=/usr/local/oracle/' '--with-apxs=/usr/local/apache-1.3.14/bin/apxs' '--with-mysql=/usr/local/mysql' '--with-gd' '--with-sablot'

Thanks!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-28 09:09 UTC] zeev@php.net
It's the programmer's responsibility to honor error_reporting in the error handler.  The error handler will be called even if the error that occured is not inside the error_reporting mask - to allow you to conduct logging, recovery, etc.

You can easily honor it by using the return value of error_reporting(), and compare it (using &) with the error level that you got.
 [2001-12-31 05:47 UTC] matthew_dean at hotmail dot com
Ah, ok, thanks. - I understand now. It was only the meaning of the @ operator I didn't follow.

I'd misinterpreted the docs.

I thought that prepending an @ set the errorNum to 0 ( either that or it suppressed the call to the error handler), when in fact it sets the global error level to 0 for the @-ed expression.

I thought the @ was: 'Supress errors'

Actually it's: 'Trigger an error as normal, but with the error level temporarily set to 0'

Thanks,
Matt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 03:01:27 2024 UTC