Jump to content
Larry Ullman's Book Forums

Chapter 12 - Script 12.7


Recommended Posts

So far so good until now.

 

In chapter 12, script 12.7 the following exists and runs fine, but I just don't understand it. In retrieving records and printing them inside the while loop:

 

print "<p><h3>{

 

From what I have seen thus far, this looks strange and don't understand why the use of the curly and not the parenthesis.

 

Can you please help me understand why replacing the curly with the parin does not work or rather why the curly is needed here?

 

Thank you and your books are awesome. I'm finally getting a grasp on PHP and in so doing is actually helping me understand JavaScript and Perl.

 

Richard Burbridge

Link to comment
Share on other sites

Thanks for the nice words, Richard. I appreciate it! 

 

The full line begins:

print "<p><h3>{$row['title']}</h3>

If you use $row['title'] within double quotes without the curly braces, you'll get a parse error. The curly braces say "Hey, here's a variable", avoiding the parse errors. That's all! 

Link to comment
Share on other sites

  • 2 weeks later...
 Share

×
×
  • Create New...