教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 smarty 安装与配置教程

smarty 安装与配置教程

发布时间:2023-05-11   编辑:jiaochengji.com
教程集为您提供smarty 安装与配置教程等资源,欢迎您收藏本站,我们将为您提供最新的smarty 安装与配置教程资源

smarty 安装与配置
1.在www.smartycssmartytest) 同时在 smartytest目录下建立如下几个目录:cache ,configs ,templates, templates_c。并且将Smarty-2.6.19下libs目录全部复制到smartytest目录下。
3.将以下代码保存到config.php中 并将文件保存到 smartytest下(smartytest/config.php
<?php
    include "libs/Smarty.class.php";
    @define('__SITE_ROOT', str_replace("[url=file://\]\","/",dirname(__FILE[/url]__)));
    $tpl = new Smarty();
    $tpl->template_dir = __SITE_ROOT . "/templates/";
    $tpl->compile_dir = __SITE_ROOT . "/templates_c/";
    $tpl->config_dir = __SITE_ROOT . "/configs/";
    $tpl->cache_dir = __SITE_ROOT . "/cache/";
    $tpl->left_delimiter = '<{';
    $tpl->right_delimiter = '}>';
?>
4. 修改php.ini中(我的是XAMPP 修改的是php/php5.ini和apache/bin/php.ini)
     ; Windows: "path1;path2"
    include_path = ".;E:xamppphppear;E:/xampp/htdocs/smartytest/libs" (指向smartytest 中的libs 绝对路径).
     改后 重启apache.
5.测试:将以下代码保存到 test.php 中 smartytest/test.php
    <?php
    require "config.php";
    $tpl->assign("title", "测试成功了,这是标题");
    $tpl->assign("content", "这是内容");
    $tpl->display('test.html');
?>
   将以下代码保存 test.html中 smartytest/templates/test.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><{$title}></title>
</head>
<body>
<{$content}>
</body>
</html>
6.运行test.php 文件(XAMPP下 http://localhost/smartytest/test.php)

您可能感兴趣的文章:
smarty缓存应用与清除
在php中配置使用smarty模板引擎
php smarty 基础
如何将smarty安装到MVC架构中(代码示例)
smarty 模板if else使用实例与入门教程
有关smarty的基本设置
有关smarty缓存的应用
smarty获得当前url示例代码
solaris系统安装配置教程详解
PHP模板引擎Smarty缓存使用

[关闭]
~ ~