PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
print '<table>';
print '<tr><th>Farenheit</th><th>Celsius</th></tr>';
// look below: you were missing ) which I've added & bolded for readability
for ($far=-50; $far <=50; $far +=5[b])[/b]{
// read note below for following line.
$celsius= ($far -32)*5/9;
print "<tr><td>$far</td><td>$celsuis</td></tr>";
}
print '</table>';
?>
</body>
</html>
I don't know if you're only going to be working in php and that's it or if you plan on going further and learning other languages. In php 5/9 will evaluate correctly, but a lot of languages will see that 5 is an integer and 9 is an integer and as such return the answer rounded to an int (in this case 0). So while it works correctly in php it's a pitfall to be careful of if you ever move over to other languages. If you plan on branching out of php ever I suggest getting into the convention of writing all floating point numbers (numbers with decimal places) with the decimal point. So I'd write that as: