ID: 17290 Comment by: naugtur at gmail dot com 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:
I've had the same problem. It reported the error in line 26, but the line was ok. I often try entering empty lines - it reveals if the error is somewhere else. The problem with this error is just trying to read something like this: $somename[] if you try: $this=$thatarray[]; without putting something between [] you get this error. Everything would be ok if PHP reported it in correct line. Please fix that! It would save people ages of looking the code through! Previous Comments: ------------------------------------------------------------------------ [2007-07-20 21:56:05] asohn at aircanopy dot net PHP 4.3.4 I got this error when mistakenly used "return $variable[];" instead of "return $variable" in a user defined function. ------------------------------------------------------------------------ [2006-06-12 13:01:07] Matt_B at TinyOnline dot co dot uk I've just had the same problem, from changing a variable from global, to class specific. After some confusion I realised I forgot to remove the $, just like in your example: $this->$resultado_array[] should be $this->resultado_array[] and then it all works fine. ------------------------------------------------------------------------ [2006-04-18 19:03:41] oliver at samera dot com dot py 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; } ?> ------------------------------------------------------------------------ [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". ------------------------------------------------------------------------ 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