首页 > Web开发 > 详细

PHP smarty模版引擎基本安装

时间:2018-05-31 01:17:33      阅读:244      评论:0      收藏:0      [点我收藏+]

环境:  PHP5.2 以上版本

 

先去官网下载smarty模版引擎的库文件到你的电脑或服务器上

smarty官方网站库文件下载地址: https://www.smarty.net/download

下载完成后解压到本地

 

技术分享图片

 

有用的是libs文件夹里面的文件,在你的www目录下新建一个smarty目录,将libs目录拷贝进smarty目录中,

特别需要注意你的templates_c文件夹必须要有可写的权限,如果实在不行,可以在本地设置为777,

chmod 777 templates_c

然后你还需要在smarty目录中创建四个文件夹templates、templates_c、cache、configs

 

技术分享图片

 

然后在你的smarty目录下的index.php(没有的话就自己新建一个)输入如下代码:

<?php
    require(‘Smarty.class.php‘);   
    $smarty = new Smarty;          
    $smarty->assign(‘name‘,‘Ryan‘);
    $smarty->display(‘index.tpl‘);

接着在templates目录下创建index.tpl文件,这个文件的后缀名称没有固定,你可以按你的项目进行命名.

在templates/index.tpl中输入如下代码:

<html>
  <head>
    <title>Smarty</title>
  </head>
  <body>
    Hello, {$name}!
  </body>
</html>

打开浏览器,输入localhost/smarty/index.php看到如下结果表示安装成功。

 

技术分享图片

 

PHP smarty模版引擎基本安装

原文:https://www.cnblogs.com/ryanzheng/p/9114548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!