#42256 [NEW]: PHP4 backwards-compatibility slightly broken

From: Date: Thu, 09 Aug 2007 13:22:18 +0000
Subject: #42256 [NEW]: PHP4 backwards-compatibility slightly broken
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115907@lists.php.net to get a copy of this message
From: mat at bcclimited dot co dot uk Operating system: Windows, Linux PHP version: 5.2.4RC1 PHP Bug Type: Class/Object related Bug description: PHP4 backwards-compatibility slightly broken Description: ------------ PHP4-style constructors do not function, in PHP5, in the same way as they do in PHP4. The issue lies in when parent constructors are called, or not as the case may be. Reproduce code: --------------- class users_base { function Users() { echo "users_base::Users()\n"; } } class Users { // Nothing here. } $base = new users_base(); $child = new Users(); Expected result: ---------------- Running the sample code in PHP4 will give the expected result: users_base::Users() users_base::Users() Whereas PHP5 will not call the Users() function in the parent class: users_base::Users() I class this as a bug because of the expected PHP5 behaviour as well as the evident PHP4 behaviour. If the users_base function is renamed to __construct(), it will get called on BOTH instantiations, as PHP4 does with its style. Actual result: -------------- users_base::Users() (The child class does not call Users() on instantiation) -- Edit bug report at http://bugs.php.net/?id=42256&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42256&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42256&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42256&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42256&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42256&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42256&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42256&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42256&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42256&r=support Expected behavior: http://bugs.php.net/fix.php?id=42256&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42256&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42256&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42256&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42256&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42256&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42256&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42256&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42256&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42256&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42256&r=mysqlcfg

« previous php.bugs (#115907) next »