Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Problem printing html tags

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Problem printing html tags

Postby segfault » Wed Nov 06, 2002 12:10 am

Here is the problem:

Code: Select all

<?php

print "<table border=1>\n";

for ($y=1; $y<=12; $y++)
   {
   print "<tr>\n";

   for ($x=1; $x<=12; $x++)
      {
      print "\t<td>";
      print "($x*$y)";
      print "</td>\n";
      }
   print "</tr>\n";
   }

print "</table>\n";

?>



This should create a table of 12*12 with numbers inside. The problem is in this line: " print "<table border=1>\n"; "

If I put quotes around the one, then php comes up with an error. Now, why is this? W3C (afaik) says that these kind of things should have quotes around them. Is this a bug in PHP? Or am I doing something wrong?

Machine running OpenBSD, Apache-1.3.26, PHP-4.2.3

Thanks for your help!
segfault
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Nov 05, 2002 11:45 pm
Location: New Zealand

Postby Jay » Wed Nov 06, 2002 3:32 am

You have to use single quotes, or if you want to use double quotes, backslash them (so they're not interpretted literally)

eg:
print "<table width='1'>\n";
or
print "<table width=\"1\">\n";
or
print '<table width="1">'."\n";

You can't mix the same quote style unless you escape the ones you want interpretted non-literally, and there is a difference between using ' and ".
Jay
 

Postby segfault » Fri Nov 08, 2002 1:45 am

Thanks very much!
segfault
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Nov 05, 2002 11:45 pm
Location: New Zealand


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron