hi

i have a class
in the first line of classe i used of:

class cpg1410_xek {
   public $GLOBALS = array();

when i run the code it showes this error:
parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/qazvin/public_html/test.php on line 9

line 9 is: public $GLOBALS = array();

when i comment this line it does not show error but i need to this line: public $GLOBALS = array();

any one can help me?

thanks

    Are you running this with PHP5? It looks like you are running this with PHP4, and so the public keyword is not recognised. Nonetheless, I strongly suggest against naming a variable $GLOBALS since it may be confused with the existing $GLOBALS superglobal array, even if you actually use it as $this->GLOBALS.

      you meanes this?:
      public $this->GLOBALS = array();

      i used of this but my problem did not solve.

        you meanes this?:
        public $this->GLOBALS = array();

        i used of this but my problem did not solve.

        No, I mean that you should not have a variable named $GLOBALS in the first place.

        The problem that you are currently facing is probably because you are using PHP4, so the PHP5 feature that allows you to specify public/protected/private scope is not available.

          Write a Reply...