This is a discussion on array as class property question within the PHP Language forums, part of the PHP Programming Forums category; Hi, I am using PHP 4 with classes but I have come across a slight problem... I can't declare ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I am using PHP 4 with classes but I have come across a slight problem... I can't declare an array as a property of a class, ie, class clTest { var $a[]; clTest() { // ...some stuff here... } DoAdd($name, $content) { $this->a[] = array("name" => $id, "content" => $content); } } This produces the error, Parse error: parse error, expecting `','' or `';'' in /srv/www/htdocs/test/table.php on line 10 line 10 is the "var $a[]". Am I missing something out or doesn't PHP4 allow arrays as properties? Julian |
|
|||
|
Julian wrote:
> Hi, > > I am using PHP 4 with classes but I have come across a slight problem... > I can't declare an array as a property of a class, ie, > > class clTest > { > var $a[]; $a = array(); <snip> > Am I missing something out or doesn't PHP4 allow arrays as properties? Yes PHP does allow that. :-) Allthough most say 'hashed array' or something like that instead of properties. (Do you come from Macromedia lingo? ;-) ) > > Julian Hope that helps. Regards, Erwin Moller |
|
|||
|
*** Julian escribió/wrote (Fri, 25 Mar 2005 11:55:33 +0000):
> var $a[]; var $a[]='foo'; or var a$; or var $a=array('foo'); or var $a=array(); -- -+ Álvaro G. Vicario - Burgos, Spain +- http://www.demogracia.com (la web de humor barnizada para la intemperie) ++ No envíes tu dudas a mi correo, publícalas en el grupo -+ Do not send me your questions, post them to the group -- |