#17290 [Fbk->NoF]: Cannot use [] for reading

From: Date: Sun, 11 Aug 2002 05:00:14 +0000
Subject: #17290 [Fbk->NoF]: Cannot use [] for reading
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16469@lists.php.net to get a copy of this message
ID: 17290 Updated by: php-bugs@lists.php.net Reported By: mellow@mellow.dk -Status: Feedback +Status: No Feedback Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 4.1.2 New Comment: No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2002-07-10 23:25:46] sniper@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. We need a self-contained and SHORT example script which shows the problem.. ------------------------------------------------------------------------ [2002-06-26 14:09:48] robjohnwilson@hotmail.com I seem to be getting this error also in 4.2.1 running on SunOS - is this possible? ------------------------------------------------------------------------ [2002-05-24 06:08:26] witterstein@web.de I occured a similar error when using (also on lx-machine) while ($db->next_record()) { /* Fix for php 4.2.1 */ $foo=$db->f('RIS_VSR_FK'); $curstate[$foo] = $db->f('RIS_ALLOWED'); /* End Fix $curmain[$db->f('RIS_VSR_FK')] = $db->f('RIS_ISMAIN'); <-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 $defmainvs = $db->f('RIS_ISMAIN') == 'YES' ? $db->f('RIS_VSR_FK') : $defmainvs; } Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ']' in xxx on line 166 <-!!!!!!!!!!!! this line That means that accessing an object in a class instance and using this as the arrays index also does not work, using a simple variable does work. Probably there is a major bug in the parser (priority?), because the workaround with $array[{$array_b[1][2]}], which I would expect that first {$array_b[1][2]} is evaluated and then $array[$evaluation_result] gets the error that no {} are allowed. I am not sure this is a new bug, but I remember in 4.0.x it always worked fine. ------------------------------------------------------------------------ [2002-05-17 11:02:29] mellow@mellow.dk I've build an array using the following in a function : ------------- $this->get_data(array("","","and D.XiParentId= 'gwak_root_element' ORDER BY D.vcOrder")); $arrCategory = $this->return_array(); for($i = 0 ; $i < sizeof($arrCategory) ; $i++) { $this->get_data(array("","","and D.XiParentId = '" . $arrCategory[$i]["XiDataId"] . "' ORDER BY D.vcOrder")); $arrItem[$arrCategory[$i]["vcItemId"]] = $this->return_array(); } return $arrItem; ------------- This constructs an array with values like : $arrItem["project_priority"][0] = array(...) $arrItem["project_priority"][1] = array(...) etc... Later I tried to do the following to the returned $arrItem : ------------- $arrItem["project_severity"][] = array("XiDataId" => "gwak_get_all", "vcText" => "All"); ------------- This gives the error : ------------- Fatal error: Cannot use [] for reading in /home/plb/public_html/gwak/module/project/include/Task.class.php on line 160 ------------- Funny because doing the following : ------------- $arrThis["here"][] = array("XiDataId" => "asdasdas", "vcText" => "324234234"); $arrThis["here"][] = array("XiDataId" => "asdasdas", "vcText" => "324234234"); $arrThis["here"][] = array("tr" => "ert"); $arrThis["where"][] = array("er" => "ert"); $arrThis["where"][] = array("we" => "ert"); $arrThis["where"][] = array("tr" => "ert"); ------------- gives no error at all, eventhough $arrThis and $arrItem have exactly the same format. Do you guys have an idea what is going on here? The only thing i can see could cause the problem is that $arrItem is built using "arrays within arrays": $arrItem[$arrCategory[$i]["vcItemId"]] = array(...); Can this be the cause or... In advance thx... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17290&edit=1

« previous php.bugs (#16469) next »