Bug #15866 Updated: using echo for expression 3 in for loop creates parse error

From: Date: Tue, 05 Mar 2002 06:29:16 +0000
Subject: Bug #15866 Updated: using echo for expression 3 in for loop creates parse error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1657@lists.php.net to get a copy of this message
ID: 15866 Updated by: derick@php.net Reported By: chunky_@hotmail.com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 4.0.6 New Comment: echo is a language construct and not a function. It's different this way from print which is a function (a built-in one). Not a bug -> Bogus Derick Previous Comments: ------------------------------------------------------------------------ [2002-03-05 00:22:42] mfischer@php.net The last sentence if wrong. print actually returns a value (as stated in the manual), maybe that's the difference. ------------------------------------------------------------------------ [2002-03-05 00:19:03] mfischer@php.net I've found such differences some time ago (but didn't care about it yet). E.g. <? $a = (echo "test\n"); var_dump($a); ?> <-- parser error <? $a = (print "test\n"); var_dump($a); ?> <-- outputs 1 'print' always evals to int(1) ------------------------------------------------------------------------ [2002-03-04 23:31:57] chunky_@hotmail.com Using Echo in expression 3 of a for loop creates a parse error. For instance: $blah = (0,1,2,3,4,5,6,7,8,9); for ($i = 0; $i < 10; echo $blah[$i++]); results in this error: Parse error: parse error, expecting `')'' in /home/chunky/public_html/test.php on line XX (line of for loop) However, this will parse properly: $blah = (0,1,2,3,4,5,6,7,8,9); for ($i = 0; $i < 10; print $blah[$i++]); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15866&edit=1

« previous php.bugs (#1657) next »