<?php
require_once('Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'd:/smartysample/var/templates/';
$smarty->compile_dir = 'd:/smartysample/var/templates_c/';
$smarty->config_dir = 'd:/smartysample/var/configs/';
$smarty->cache_dir = 'd:/smartysample/var/cache/';
$smarty->assign('title', 'Fruit');
$smarty->assign('fruit', new Fruit('Apple', '80'));
$smarty->display('sample4-1.tpl');
class Fruit{
public $name;
public $price;
function __construct($name, $price){
$this->name = $name;
$this->price = $price;
}
public function getPrice(){
return $this->price;
}
}
?>