|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-14 13:04 UTC] 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));
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 26 09:00:01 2026 UTC |
Then convert array to object this way: <?php $a = array('a'=>'b', 'foo'=> 'bar'); var_dump((object)$a); ?>