PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Variables assigned from PHP

Assigned variables that are referenced by preceding them with a dollar ($) sign.

Example 22. Assigned variables

PHP code



<?php

$smarty 
= new Smarty();

$smarty->assign('firstname''Doug');
$smarty->assign('lastname''Evans');
$smarty->assign('meetingPlace''New York');

$smarty->display('index.tpl');

?>

index.tpl source:


Hello {$firstname} {$lastname}, glad to see you can make it.
<br />
{* this will not work as $variables are case sensitive *}
This weeks meeting is in {$meetingplace}.
{* this will work *}
This weeks meeting is in {$meetingPlace}.

   

This above would output:


Hello Doug Evans, glad to see you can make it.
<br />
This weeks meeting is in .
This weeks meeting is in New York.

  

Smarty Template Engine