Results 1 to 4 of 4

Thread: How to Handle the Error Control Operator in PHP

  1. #1
    Join Date
    Nov 2008
    Posts
    240

    How to Handle the Error Control Operator in PHP

    In my error handler, I need to be able to detect when the error-control operator was used to suppress errors, because some external libraries (sadly) use it a lot and I sees some documentation: where they have mentioned the following things "error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. What is it how do I deal with it.

  2. #2
    Join Date
    Jan 2009
    Posts
    99

    Re: How to Handle the Error Control Operator in PHP

    If the track_errors feature is enabled, any error message generated by the expression will be saved in the variable $php_errormsg. Operator precedence is working against you in this instance. The operation involving offset operation is before before the error blocking operator is considered. This variable will be overwritten on each error, so check early if you want to use it.
    PHP Code:
    <?php

    function ErrorHandler() {
        
    var_dump(error_reporting()); // 0
    }

    set_error_handler('ErrorHandler');
    echo @
    $a[1];
    ?>

  3. #3
    Join Date
    Feb 2009
    Posts
    105

    Re: How to Handle the Error Control Operator in PHP

    The undefined index error was pre-apended by the error-control operator. I understand that this will still call my error handler callback, but it should have set the value of $iErr to 0. At the conclusion of performance training events, there is usually some form of assessment of the knowledge gained or a demonstration of skills learned.

  4. #4
    Join Date
    Oct 2008
    Posts
    42

    Re: How to Handle the Error Control Operator in PHP

    The @-operator works only on expressions. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. Operator precedence is working against you in this instance. For instance, you can prepend it to variables, function and include() calls, constants, and so forth. You cannot prepend it to function or class definitions, or conditional structures such as if and foreach, and so forth.

Similar Threads

  1. how to get control handle from dll
    By ronaldobrazil in forum Software Development
    Replies: 3
    Last Post: 15-06-2012, 02:19 PM
  2. Replies: 5
    Last Post: 07-07-2011, 06:28 AM
  3. Error Control and flow control in TCP/IP?
    By Diellza in forum Networking & Security
    Replies: 5
    Last Post: 07-01-2011, 09:36 AM
  4. Flash Content Error 7 - Unable To Handle
    By Udayachal in forum Software Development
    Replies: 4
    Last Post: 21-04-2010, 04:44 PM
  5. Error in Operator Overloading
    By DutchDude in forum Software Development
    Replies: 2
    Last Post: 13-05-2009, 11:54 PM

Tags for this Thread

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
  •  
Page generated in 1,713,530,237.50853 seconds with 17 queries