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:
02 | require 'Smarty/libs/Smarty.class.php' ; |
07 | var $email = 'wsiswoutomo at yahoo dot com' ; |
08 | var $phone = '123456789' ; |
11 | $contact = new Contacts; |
15 | $smarty ->assign( 'title' , 'Contact Detail' ); |
16 | $smarty ->assign( 'contact' , $contact ); |
17 | $smarty ->display( 'test.tpl' ); |
Next, build template by create a file named "test.tpl" within template. Enter following code
03 | <title>{ $title }</title> |
06 | id : { $contact ->id} <br> |
07 | name : { $contact ->name} <br> |
08 | email : { $contact ->email} <br> |
09 | phone : { $contact ->phone} <br> |
0 comments:
Post a Comment