ID: 28459 Updated by: [EMAIL PROTECTED] Reported By: alpzrjvr at hotmail dot com -Status: Verified +Status: Bogus Bug Type: Documentation problem Operating System: Slackware 9.0, Windows XP PHP Version: 4.3.8 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Dup of bug #22253. Previous Comments: ------------------------------------------------------------------------ [2004-05-20 20:04:59] alpzrjvr at hotmail dot com Description: ------------ http://cr2.php.net/language.oop.constructor PHP manual says: In PHP 3, the function B() in class A will suddenly become a constructor in class B, although it was never intended to be. The rule in PHP 3 is: 'A constructor is a function of the same name as the class.'. PHP 3 does not care if the function is being defined in class B, or if it has been inherited. This is fixed in PHP 4 by modifying the rule to: 'A constructor is a function of the same name as the class it is being defined in.'. Thus in PHP 4, the class B would have no constructor function of its own and the constructor of the base class would have been called, printing 'I am the constructor of A.<br />'. But, I test the script in diferent PHP's versions and the result was: "I am a regular function named B in class A. I am not a constructor in A." ... with PHP 4.x.x . Reproduce code: --------------- <? class A { function A() { echo "I am the constructor of A.<br />\n"; } function B() { echo "I am a regular function named B in class A.<br />\n"; echo "I am not a constructor in A.<br />\n"; } } class B extends A { function C() { echo "I am a regular function.<br />\n"; } } $b = new B(); or $b = new B; (also works) ?> Expected result: ---------------- I am the constructor of A. Actual result: -------------- I am a regular function named B in class A. I am not a constructor in A. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28459&edit=1