#42256 [Opn->Csd]: PHP4 backwards-compatibility slightly broken

From: Date: Thu, 16 Aug 2007 08:51:58 +0000
Subject: #42256 [Opn->Csd]: PHP4 backwards-compatibility slightly broken
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969377371@lists.php.net to get a copy of this message
ID: 42256 Updated by: vrana@php.net Reported By: mat at bcclimited dot co dot uk -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Windows, Linux PHP Version: 5.2.4RC1 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. "In PHP 5, function with the name of a class is called as a constructor only if defined in the same class. In PHP 4, it is called also if defined in the parent class." Previous Comments: ------------------------------------------------------------------------ [2007-08-10 09:41:51] mat at bcclimited dot co dot uk I wouldn't say "clearly"... It kind of makes sense the way PHP4 works, and I'd expect that any features that claim to be backwards-compatible work in the same way as the old version, else the claim is fallacious. I assume that the PHP4 interpreter looks at all available functions for one matching the class name and calls it if it exists, whereas PHP5 only looks in the functions implemented in that class and does not traverse up to the parent - making it behave as if the function was not inherited. I take it this is a "will not fix"/"not broken" status, and I need to recode all the classes that are constructed like this? :( ------------------------------------------------------------------------ [2007-08-10 01:25:42] judas dot iscariote at gmail dot com Interesting ;) the documentation should also mention that the old PHP4 beahviuor is clearly the wrong thing. ------------------------------------------------------------------------ [2007-08-09 15:01:28] jani@php.net Reclassified. ------------------------------------------------------------------------ [2007-08-09 13:40:03] mat at bcclimited dot co dot uk Nuts, typo. Both the Users should start: class Users extends users_base { ------------------------------------------------------------------------ [2007-08-09 13:26:22] mat at bcclimited dot co dot uk Oh, thought I'd add a workaround: class Users { function Users() { parent::Users(); } } Unfortunately for me, there are one hell of a lot of classes that our previous programmer built in this fashion, making the workaround impractical. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/42256 -- Edit this bug report at http://bugs.php.net/?id=42256&edit=1

« previous php.doc (#969377371) next »