I ran across a curious bug in the echo function this morning.  My PHP is
Debian binary 4.1.1-1.

The first example below does not work (it should draw a
checkerboard-like table):

-----

<html>
<head>
<title>Chess</title>
<body>
<table border=1>
<?

for ($i=0 ; $i<8 ; $i++) {
  echo "<tr align=center valign=center>";
  for ($j=0 ; $j<8 ; $j++) {
    echo "<td>" . ($i*8)+$j . "</td>";
  }
  echo "</tr>\n";
}

?>
</table>
</body>
</html>

-----

However, by changing the echo line to two echo lines, it works as
desired:

-----

<html>
<head>
<title>Chess</title>
<body>
<table border=1>
<?

for ($i=0 ; $i<8 ; $i++) {
  echo "<tr align=center valign=center>";
  for ($j=0 ; $j<8 ; $j++) {
    echo "<td>";
    echo ($i*8)+$j . "</td>";
  }
  echo "</tr>\n";
}

?>
</table>
</body>
</html>

-----

I don't see any limitations about concatenating strings in the man page
of the echo statement.  Perhaps this is a bug?

Billy



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to