Consider the
following example in which some CSS markup is embedded into the template:
Welcome, {$user}{literal}
{/literal}
...
Neglecting to enclose the CSS information within the literal brackets would
result in a Smarty-generated parsing error because it would attempt to make sense of
the curly brackets found within the CSS markup (assuming that the default curly-bracket
delimiter hasn??™t been modified).
The php Statement
You can use the php statement to embed PHP code into the template. Any code found
within the {php}{/php} tags will be handled by the PHP engine. An example of a
template using this function follows:
Welcome to my Web site.
{php}echo date("F j, Y"){/php}
CHAPTER 19 ?– TEMPLAT ING WITH SMARTY 493
This is the result:
Welcome to my Web site.
February 23, 2008
?– Note Another function similar to php is include_php. You can use this function to include a separate
script containing PHP code in the template, allowing for cleaner separation. Several other options
are available to this function; consult the Smarty manual for additional details.
Creating Configuration Files
Developers have long used configuration files as a means for storing data that determines
the behavior and operation of an application. For example, the php.ini file is
responsible for determining a great deal of PHP??™s behavior.
Pages:
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574