Reply to Re: Class question. Where am I going wrong?

Your name:

Reply:


Posted by Adam on 10/06/06 12:29

Mateusz Markowski wrote:
> Adam napisal(a):
> > class matrix {
> > public $row1 = &new row();
> > public $row2 = &new row();
> > public $row3 = &new row();
> > public $row4 = &new row();
> > public $row5 = &new row();
> > public $row6 = &new row();
> > public $row7 = &new row();
> > public $row8 = &new row();
> > public $row9 = &new row();
> > }
> >
> > The problem is is that I guess I cannot use objects within another
> > class since this code errors. (Parse error: syntax error, unexpected
> > T_NEW in yadda/yadda/yadda.php). Could someone take a second to set me
> > right and kindly point me in the right direction? I have a feeling I
> > am just not looking at this problem correctly.
>
> A default class property must be string, number or array. "new"
> operator is not allowed.
> Why are creating so many properties instead an array of them? Try:
>
> class Matrix {
> private $rows = array();
> public function __construct($howmany)
> {
> for ($i=0;$i<$howmany;$i++) {
> $this->rows[$i] =new Row();
> }
> }
> }

I dont know why I am not using an array. I think I am getting confused
on objects and I am losing my mind :) What is the reasoning behind why
default class properties only being a string, number, or array? I think
knowing that would help me understand better. Thanks for your help
Mateusz!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация