PHP5.2 Smarty2.6.18 Coherent

In my comany project,due to no time to manage the web structure(php), only leave the pure php files and other scripts in my project.from now on,under the cerntain situation, and with the project on-going and extension,need apply some new style to reorganize the project, The first step is: separate the display and logics. then I select the smarty template as the cutting-point. what's more,I put down the configure.
1.Download Smarty package  http://smarty.php.net/
2.Create a directory in web root such as app,then copy the libs folder under the smarty package to app folder.(my web root :C:/work/wwwroot)
3.Modify the php.ini for supporting the smarty template. add this in the php.ini:include_path=".;C:\Work\wwwroot\app\libs"
4.create templates,templates_c,configs,cache folders in the app directory.
5.write down index.php file in the app directory :
<?php
// load Smarty library
require('libs/Smarty.class.php');$smarty = new Smarty;$smarty->template_dir = 'templates';
$smarty->config_dir = 'config';
$smarty->compile_dir = 'templates_c';
$smarty->cache_dir = 'cache';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
6.create a template file(index.tpl) in the templates folder:
<html>
<body>
Hello, {$name}!
</body>
</html>

Basically the directory structure is:
 
wwwroot
              +app
                      +libs(files from smarty libs folder)
                      +templates(put the tpl file in this directory)
                      templates_c
                      configs
                      cache


7.run this http://localhost/app

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值