2
<h1>Score and Prize</h1>
<table border="1">
<tr>
<th bgcolor="skyblue">SCORE</th>
<th bgcolor="skyblue">PRIZE</th>
</tr>
<?php
$num = 1;
while ($num <= 5){
echo "<tr>
<td>".$num * 50 . "</td>
<td>". $num * 1000 . "</td>
</tr>";
$num++;
}
?>

This is a loop to make a table. In the php code, I found out that

<td>".$num * 50 . "</td>

This is working, but

<td>".$num * 50. "</td>

This is not working. And only difference is a space between number '50' and '.'. Why is this happening?

Kim
  • 79
  • 1
  • 1
  • 4
  • 1
    Please consider properly indenting your code before posting it in Stack Overflow, it helps people who might answer your question to find the problem faster. – Benjamin Gruenbaum Jun 02 '14 at 23:52

1 Answers1

6

php is parsing the 50. as a floating point number, and so it no longer sees the '.' as a string concatenation operator.

cnick
  • 332
  • 2
  • 11