Smarty Variable Step by Step Tutorial - Part 1: Following sample using associative array at smarty:
Create a file named "test.php" enter following code:
<?php
require 'Smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->assign('title','Contact Detail');
$smarty->assign('contact',array('id'=>1,
'name'=>'Wiwit',
'email'=>'wsiswoutomo at yahoo dot com',
'phone'=>'123456789'
));
$smarty->display('test.tpl');
?>
Next, build template by create a file named "test.tpl" within template. Enter following code
<html>
<head>
<title>{$title}</title>
</head>
<body>
id : {$contact.id} <br>
name : {$contact.name} <br>
email : {$contact.email} <br>
phone : {$contact.phone} <br>
</body>
</html>
advertisements
blog comments powered by Disqus

