RE: object literals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



var o = {
    "a" : "b",
    "c" : "d"
};

$o = array(
    'a' => "b",
    'c' => "d"
);

so I guess the problem is a couple of quotes, isn't it?


otherwise define object statically and externally and use json_decode ;-)




> Date: Thu, 30 Apr 2009 16:56:21 -0400
> From: fsb@xxxxxxxxxx
> To: php-general@xxxxxxxxxxxxx
> Subject:  object literals
> 
> is there a neat literal syntax for creating objects on the fly without
> defining a type?
> 
> whenever i need to do it i do something like
> 
>     $x = (object) array('a'=>1, 'b'=>3, ...);
> 
> which works but isn't very lovely. it's neater in, for example, javascript.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

_________________________________________________________________
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux