O'Reilly logo

Learning PHP, MySQL, and JavaScript by Robin Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12 Answers

Question 12-1

There are several benefits to using a templating system such as Smarty. They include but are not limited to:

  • Separating the program code from the presentation layer.

  • Preventing template editors from modifying program code.

  • Removing the need for programmers to design page layout.

  • Allowing the redesign of a web page without modifying any program code.

  • Enabling multiple “skin” designs with little recourse to modifying program code.

Question 12-2

To pass a variable to a Smarty template, a PHP program uses the $smarty->assign function.

Question 12-3

Smarty templates access variables passed to them by prefacing them with a dollar sign $ and enclosing them with curly braces {}.

Question 12-4

To iterate through an array in a Smarty template, you use the opening {section} and closing {/section} tags.

Question 12-5

If Smarty has been installed, you can enable it in a PHP program by including the Smarty.class.php file from its correct location (normally in a folder called Smarty, just under the document root).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required