ID:               17290
 Comment by:       oliver at samera dot com dot py
 Reported By:      mellow at mellow dot dk
 Status:           No Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      4.1.2
 New Comment:

Seems to be a class related bug, here is a simple test-case:

<?php
// php 4.3.9 - CentOS 4.3 - [EMAIL PROTECTED] - 18-apr-2006

//
-----------------------------------------------------------------------------
class cache_db {
        var $resultado_array;

        function cache_db() {
                $this->$resultado_array = array();
        }

        // abre un archivo y lo carga en memoria
        function cache_open() {
                $archivo_array = array(array('1'), array('2'), array('3'));
                $resultado_array = array();

                foreach($archivo_array as $linea) {
                        $resultado_array[] = $linea;
                        $this->$resultado_array[] = $linea;
                }
        }
}

// without a class
$archivo_array = array(array('1'), array('2'), array('3'));
$resultado_array = array();

foreach($archivo_array as $linea) {
        $resultado_array[] = $linea;
}

?>


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

[2006-03-18 21:17:37] 7l9it46r1adm1l1 at jetable dot com

I got the same strange Fatal error (using Windows XP, PHP PHP 5.0.4):
Fatal error: Cannot use [] for reading in ... on line 82

[php]
if ($insert->check($_POST['value']) === FALSE)
{
   $error[] == 'Error'; // line 82
}
[/php]

Zend Developer didn't give any warnings so there shouldn't be any
syntax mistakse in that PHP file.

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

[2002-08-11 01:00:13] php-bugs at lists dot php dot net

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".

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

[2002-07-10 23:25:46] [EMAIL PROTECTED]

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 at hotmail dot 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 at web dot 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.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/17290

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

Reply via email to