PHP 4.0 Bug #9576: Parse error with ($i%2) ? echo '':echo''

From: Date: Tue, 06 Mar 2001 12:09:01 +0000
Subject: PHP 4.0 Bug #9576: Parse error with ($i%2) ? echo '':echo''
Groups: php.dev 
Request: Send a blank email to php-dev+get-48027@lists.php.net to get a copy of this message
From: yasuo_ohgaki@hotmail.com Operating system: RedHat Linux v7.0.1/j PHP version: 4.0.4pl1 PHP Bug Type: Scripting Engine problem Bug description: Parse error with ($i%2) ? echo '':echo'' Miner parser bug. PHP4.0.4pl1 on my Linux (PHP is running as Apache 1.3.17 module) gives parse error with following code. <tr class=<?php ($i % 2) ? echo('even') : echo('odd') ?>> This one works as expected <tr class=<?php ($i % 2) ? print('even') : print('odd') ?>> Hope this helps. --- Yasuo Ohgaki === SOURCE BEGIN ==== <html> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP"> <link rel="stylesheet" href="../lib/css/std.css"> <style type="text/css"> <!-- .odd { background: #CCCCFF} .even { background: #CCCCCC} --> </style> </head> <body bgcolor="#FFFFFF"> <table width="80%" border="2" cellspacing="1" cellpadding="1"> <?php for ($i = 0; $i < 100; $i++) { ?> <!-- <tr class=<?php if ($i % 2 == 0) echo('even'); else echo('odd'); // OK?>> --> <!-- <tr class=<?php ($i % 2) ? print('even') : print('odd'); // OK ?>> --> <tr class=<?php ($i % 2) ? echo('even') : echo('odd'); // NOT OK ?>> <td>@</td> <td>@</td> </tr> <?php } // END for( ) loop ?> </table> </body> </html> ==== END SOURCE ==== -- Edit Bug report at: http://bugs.php.net/?id=9576&edit=1

« previous php.dev (#48027) next »