#34500 [Opn]: change stdClass constructor prototype

From: Date: Wed, 14 Sep 2005 11:06:11 +0000
Subject: #34500 [Opn]: change stdClass constructor prototype
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85021@lists.php.net to get a copy of this message
ID: 34500 User updated by: stochnagara at hotmail dot com Reported By: stochnagara at hotmail dot com Status: Open Bug Type: Feature/Change Request PHP Version: 5CVS-2005-09-14 (snap) New Comment: I forgot: 'a' and 'b' become class members so echo $obj->a prints 2 and echo $obj->b prints 3. Previous Comments: ------------------------------------------------------------------------ [2005-09-14 13:04:27] stochnagara at hotmail dot com Description: ------------ I think it will be very useful to modify stdClass constructor from __construct() to __construct ($fields = array()). This will make stdClass easier to work with like arrays. Reproduce code: --------------- $array = array ('a' => 2, 'b' => 3); $obj = new stdClass; $obj->a = 2; $obj->b = 3; //Not supported $obj = new stdClass (array ('a' => 2, 'b' => 3)); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34500&edit=1

« previous php.bugs (#85021) next »