Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Can this be done? I'm trying to initialise an array variable $x which is a static member of a class. As follows:Code: Select all
class CMyObj
{
var $a;
var $b;
function
__construct($a,$b)
{
$this->a = $a;
$this->b = $b;
}
}Code: Select all
var $x = array(new CMyObj(1,2),new CMyObj(3,4));I've tried various incantations of the syntax but I can't make this work. I believe array() is supposed to take key=>value pairs, or values alone (implied numeric keys), and value supposedly can be anything, therefore why not an object?
twigletmac | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]