Archive for the ‘PHP6’ Category

Being E_STRICT

No Comments »

The issue: PHP has a new error level E_STRICT, since PHP 5.0.

E_STRICT forces you to code clean PHP 5 code
Current E_STRICT will most probably become E_FATAL in PHP 6.0
The resolution: Switch E_STRICT on and check your code

    error_reporting=E_ALL | E_STRICT

Typical E_STRICT error – Usage of outdated is_a() function

<?php
if ( is_a( $object, 'ClassName' ) ) {
    $object->foo();
}
?>

Should be now

<?php
if ( $object instanceof ClassName ) {
    $object->foo();
}
?>