PHP Programming with E_STRICT beware!

I recently switched to programming PHP with error_reporting set to E_STRICT, since I want to know what’s going on. You have to watch out when extending classes and trying to overrule the parameters of the child method. An example:

php-e-strict-errors

When executing you will get the following error “Strict Standards: Declaration of B::test() should be compatible with that of A::test() in /path/to/file/test.php on line 18

When I remove the parameter ‘value’ from the method ‘test’ in the class ‘B’, everything’s fine. Write that down.

3 Thoughts on “PHP Programming with E_STRICT beware!

  1. and if you set the ‘value’ parameter to a default value, does it give an error too?

  2. You either have to add the parameter $value in class A or remove it from class B.

  3. remove class B

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation