Blogroll

photoshop cs6 html 5 css php seo backlinks

adsense

Monday, 24 February 2014

Use of Associative Arrays: Smarty Variable

Smarty Variable Step by Step Tutorial - Part 1: Following sample using associative array at smarty:
Create a file named "test.php" enter following code:
01<?php
02require 'Smarty/libs/Smarty.class.php';
03 
04$smarty = new Smarty;
05 
06$smarty->assign('title','Contact Detail');
07$smarty->assign('contact',array('id'=>1,
08                                'name'=>'Wiwit',
09                                'email'=>'wsiswoutomo at yahoo dot com',
10                                'phone'=>'123456789'
11                                ));
12$smarty->display('test.tpl');
13?>
Next, build template by create a file named "test.tpl" within template. Enter following code
01<html>
02  <head>
03    <title>{$title}</title>
04  </head>
05  <body>
06    id : {$contact.id} <br>
07    name : {$contact.name} <br>   
08    email : {$contact.email} <br>   
09    phone : {$contact.phone} <br>   
10  </body>
11</html>

0 comments:

Post a Comment