Problems with error_reporting() in PHP5?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pedro Fonseca

    Problems with error_reporting() in PHP5?

    Greetings everyone!

    I'm porting my applications to PHP5 and I've stumbled on yet another
    problem. I'll try to simplify things a bit. I have a main script that
    is being executed (index.php, PHP5 script) and that is including 2
    other files: config.inc (PHP5 script, for the configuration) and
    adodb.inc.php (PHP4 script, ADOdb functionality, though it could be
    any other PHP4 script). On php.ini, error_reporting = E_ALL|E_STRICT.
    These are the contents of the files:

    - index.php:
    <?php
    include('config .inc');
    include('adodb. inc.php');
    ?>

    - config.inc:
    <?php
    error_reporting (E_ALL|E_STRICT );
    ?>

    - adodb.inc.php:
    <?php
    error_reporting (E_ALL & ~E_STRICT);
    // Following is the rest of the script with PHP4 things like:
    class whatever {
    var x;
    ......
    }
    ?>

    Now, what I was expecting was to have E_ALL and E_STRICT turned on
    (because config.inc is included) and then, when parsing adodb.inc.php,
    only E_ALL would be active. After adodb.inc.php is parsed, normal
    behaviour set before by config.inc (i.e. E_ALL|E_STRICT) would be
    resumed again.

    But alas, this is not happening. The error_reporting () that I added to
    the beginning of adodb.inc.php is not doing anything, since I keep
    getting Strict Standards warnings in the adodb.inc.php file, saying
    among other things that var is deprecated...

    I'd like to have my new PHP5 application to have all the E_STRICT
    warnings turned on, only turning them off for specific third party
    scripts that are not completely compatible with that directive...

    Is this a little bug with the error_reporting () in PHP5? Or what is
    the problem?
  • Pedro Fonseca

    #2
    Re: Problems with error_reporting () in PHP5?

    OK, for the sake of this knownledge on usenet, I'll post the solution
    to my own problem, that in the meantime I got to solve.

    So, instead of the original code I had, the correct code is:

    - index.php:
    <?php
    include('config .inc');
    // Begin 3rd party library inclusion
    $old = error_reporting (E_ALL & ~E_STRICT);
    include('adodb. inc.php');
    error_reporting ($old);
    // End 3rd party library inclusion
    ?>

    - config.inc:
    <?php
    // NO LONGER NECESSARY:
    // error_reporting (E_ALL|E_STRICT );
    ?>

    - adodb.inc.php:
    <?php
    // NO LONGER NECESSARY:
    // error_reporting (E_ALL & ~E_STRICT);
    // Following is the rest of the script with PHP4 things like:
    class whatever {
    var x;
    ......
    }
    ?>

    Thank me. :-)

    Comment

    Working...