For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > June 2006 > #37880 [Opn]: Cannot initialize multiline associative array in declaration portion of









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #37880 [Opn]: Cannot initialize multiline associative array in declaration portion of
colder@php.net

2006-06-24, 8:03 am

ID: 37880
Updated by: colder@php.net
Reported By: cuervo_4762 at yahoo dot com
Status: Open
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 5.1.4
-Assigned To:
+Assigned To: colder
New Comment:

Class members' default values can only be scallar "fixed" values.

Here is some assignations considered "dynamic" and thus invalid:

public $var = 1+2;
public $var = $anothervar;
public $var = <<<EOD
blabla
EOD;
public $var = 'foo'.'bar';
public $var = myFunction();

This should indeed be properly documented, I'll provide a patch ASAP.


Previous Comments:
------------------------------------------------------------------------

[2006-06-22 19:05:55] tony2001@php.net

Reclassified as docu problem.

------------------------------------------------------------------------

[2006-06-21 23:18:49] cuervo_4762 at yahoo dot com

Description:
------------
I cannot seem to initialize a multi-line assoc array in the declaration
part of a class. The work around I am using is to do it in the
constructor. If this is the normal behavior it problaly should be
stated in the manual.

thanks
frank

Reproduce code:
---------------
<?php
class RDBMSLoginDataSource {

private $_dsn;
private $_mdb2 = 2;

private $_sql = array(
'isUserLocked'=>"SELECT users.is_locked FROM users where ".
"user_name='$user' LOCK IN SHARE MODE",
'userLogin' =>"SELECT users.user_name,COUNT(*) FROM " .
"users WHERE users.user_name='$user' && ".
"users.pass='$pass' GROUP BY " .
"users.user_name LOCK IN SHARE MODE"
);
}

?>

Expected result:
----------------
na

Actual result:
--------------
Parse error: syntax error, unexpected '.', expecting ')' in
/home/fmadero/public_html/classes/RDBMSLoginDataSource.php on line 8



------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=37880&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com