Page 1 of 1

php echo tag not rendering my html code why?

Posted: Tue Oct 06, 2009 8:25 pm
by imsoconfused
Why isin't the html table rendering? I know I could just close the php tag and put the html after but i am working on something more complex that deals with this concept.

Code: Select all

<!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
echo "<table border="1">";
echo "<tr>";
echo "<td>row 1, cell 1</td>";
echo "<td>row 1, cell 2</td>";
echo "</tr>";
echo "<tr>";
echo "<td>row 2, cell 1</td>";
echo "<td>row 2, cell 2</td>";
echo "</tr>";
echo "</table>";
  
  
 ?>
 
</body>
</html>

Re: php echo tag not rendering my html code why?

Posted: Tue Oct 06, 2009 8:41 pm
by veldthui
Have not checked this but would assume it is because of

echo "<table border="1">";

May be you should use

echo '<table border="1">';

or escape the " around the 1

Re: php echo tag not rendering my html code why?

Posted: Tue Oct 06, 2009 8:56 pm
by imsoconfused
Awesome thanks,

Changing double quote to single quote is the answer

Code: Select all

echo '<table border="1">';