New E_STRICT Error Setting
PHP 5’s new
E_STRICT error setting issues a warning when you
use deprecated features. Specifically, it complains when you:
Create objects without a class definition
Use a constructor named after the class instead of
_ _construct( )Use
varinstead ofpublicUse
is_a( )instead ofinstanceofCopy an object instead of making a reference (requires
zend.ze1_compatibility_modeto beOn)Statically invoke a nonstatic method
Refine the prototype of an inherited method other than
_ _construct( )Return a nonvariable by reference
Assign the object returned by
newby reference
All of these features work in PHP 5, but you should slowly modify your code to stop using them. Here are a few examples:
This code automagically creates
$personas an object without a class definition:$person->name = 'Rasmus Lerdorf';
PHP Strict Standards: Creating default object from empty valueThis
Personclass usesvarinstead ofpublic(or, even better,private). It also defines two constructors:class Person { var $name; function _ _construct($name) { $this->name = $name; } function Person($name) { $this->name = $name; } }PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiersPHP Strict Standards: Redefining already defined constructor for class Person
E_STRICT is not enabled by default, nor is it part
of E_ALL. To enable it, set your
error_reporting
configuration directive to E_ALL | E_STRICT.
Setting E_STRICT within a PHP script using
error_reporting( ...