Equivalent ways to populate an array.

From: Date: Wed, 10 Jan 2001 06:56:11 +0000
Subject: Equivalent ways to populate an array.
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-4898@lists.php.net to get a copy of this message
I can successfully populate the params array in this way: class MyDB extends DB { var $params = array( 'phptype' => "mysql", 'hostspec' => "localhost", 'database' => "testdb", 'username' => "root", 'password' => "" ); } Then I try to do it this way: class MyDB extends DB { var $params = array(); $this->params['phptype'] = "mysql"; $this->params['hostspec'] = "localhost"; $this->params['database'] = "testdb"; $this->params['username'] = "root"; $this->params['password'] = ""; } I get this error for the second way: Parse error: parse error, expecting T_OLD_FUNCTION' or T_FUNCTION' or T_VAR' or '}'' in c:/apache/htdocs/004.php on line 15 Line 15 is this line: $this->params['phptype'] = "mysql"; I also tried populating the array by dropping $this-> and just having $params['phptype'] = "mysql"; but I still get the same error. Anybody know why I am getting this error? Regards, Paul

« previous php.windows (#4898) next »