|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2010-06-23 15:21 UTC] manannon at seatiger dot org
 Description: ------------ The following class generates the E_STRICT warning: Strict standards: Redefining already defined constructor for class Log. However according to http://php.net/manual/en/language.oop5.decon.php, PHP5 will only assume log() is a constructor if it cannot find a __construct() method: "For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class." Since it has already found a __construct() method, it should not assume that log() is also a constructor. Test script: --------------- <?php class Log { public function __construct() { } public static function log() { } } Expected result: ---------------- Nothing Actual result: -------------- Strict standards: Redefining already defined constructor for class Log in .... PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
"Since it has already found a __construct() method, it should not assume that log() is also a constructor." Yes, It should not, and actually does not do this. But the E_STRICT is emitted for both cases, though. I.e.: class foo { function foo() { } function __construct() { } // E_STRICT + redefinition } class bar { function __construct() { } function bar() { } // E_STRICT only } However, we should change the message for the late.