Re: sytax error, but where?



Janwillem Borleffs wrote:
carlton wrote:

I added the var to line 44, and now get the error
Parse error: parse error, unexpected '[', expecting ',' or ';' in
/var/www/html/lc.php on line 44

line 44 is var $PictureList[] = new C_PictureList();



You should assign $PictureList in the constructor or with a setter:

class C_Category {
    var $PictureList = array();

    function C_Category() {
        $this->PictureList[] = new C_PictureList();
    }
}


JW



PictureList[] is supposed to be an array of C_PictureList objects, not a member of the C_PictureList class.
.




Relevant Pages

  • Re: hpricot
    ... It just gave me "test.rb:1: parse error, ... tIDENTIFIER, expecting $"... ... Seven Deadly Sins? ...
    (comp.lang.ruby)
  • Re: PHP5 Dom XML dynamic Table Generation
    ... I keep getting the following output in my browser when attempting this. ... Parse error: syntax error, unexpected ';', expecting ']' in ...
    (alt.php)
  • Parse error showing with display_errors = off
    ... Parse error: syntax error, unexpected '{', expecting '(' in C:\Inetpub ... please forgive my ignorance. ...
    (php.general)
  • HELP PLZ: sessions and echo variables problem
    ... Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ... echo 'Sorry you do not have access to this page'; ... I am guessing that its the php code thats on ...
    (alt.php)
  • Re: hpricot
    ... It just gave me "test.rb:1: parse error, ... tIDENTIFIER, expecting $"... ... I'm running ruby 1.8.5 with Hpricot 0.4.43 and I just cut and pasted the above code. ...
    (comp.lang.ruby)