|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-02-03 12:05 UTC] jani@php.net
[2010-02-03 12:40 UTC] pieterbregman1982 at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 11:00:01 2025 UTC |
Description: ------------ PHP reports a strict error when classes are being included using include() (or require()). This error doesn't come up when the classes are in the scope allready by inlining them in the same file that makes the calls to the classes. I can't figure out why the error only occurs when the classes are being included by using include() Reproduce code: --------------- test1.php (This code gives no strict errors) <?php ini_set('display_errors', '1'); error_reporting(-1); abstract class Model { public function create() { echo __CLASS__; } } class Person extends Model { public function create($name) { echo $name; } } $person = new Person(); $person->create('Foo'); ?> test2.php (This code does give a strict error) <?php ini_set('display_errors', '1'); error_reporting(-1); include_once 'Model.php'; include_once 'Person.php'; $person = new Person(); $person->create('Foo'); ?> Model.php <?php abstract class Model { public function create() { echo __CLASS__; } } ?> Person.php <?php class Person extends Model { public function create($name) { echo $name; } } ?> Expected result: ---------------- I would expect that both tests don't give strict errors. Actual result: -------------- test02.php - Strict error: Strict standards: Declaration of Person::create() should be compatible with that of Model::create() in Person.php on line 6