Blogroll

photoshop cs6 html 5 css php seo backlinks

adsense

Monday, 24 February 2014

Use of Object: Smarty Variable

Smarty Variable Step by Step Tutorial - Part 3: In this post, we will see how to access data from a class.
Create a file named "test.php" enter following code:
01<?php
02require 'Smarty/libs/Smarty.class.php';
03 
04class Contacts{
05  var $id   = 1;
06  var $name = 'wiwit';
07  var $email = 'wsiswoutomo at yahoo dot com';
08  var $phone = '123456789';
09}
10 
11$contact = new Contacts;
12 
13$smarty = new Smarty;
14 
15$smarty->assign('title','Contact Detail');
16$smarty->assign('contact',$contact);
17$smarty->display('test.tpl');
18?>
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