日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php怎么安装模板_php 模板框架之smarty 的下载和安装

發(fā)布時間:2024/8/1 php 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php怎么安装模板_php 模板框架之smarty 的下载和安装 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Smarty 官網(wǎng):

http://www.smarty.net/

Smarty 下載:

https://github.com/smarty-php/smarty/releases/tag/v3.1.30

// 下載 tar.gz 放到你的網(wǎng)站服務(wù)器中,和 jQuery和 Bootstrap 配合使用。

Smarty 使用例程

// 假設(shè) Smarty 框架已經(jīng)解壓在 /var/www 目錄下,此目錄是apache2 的家目錄

// 現(xiàn)在,先寫一個main.php

// main.php

include "smarty-3.1.30/libs/Smarty.class.php";

define ("__SITE_ROOT", "/var/www");

require_once('includes/include.php');

require_once('includes/functions.php');

$tpl = new Smarty();

$tpl->template_dir = __SITE_ROOT . "/templates/"; // 指定模板目錄

$tpl->compile_dir = __SITE_ROOT . "/templates_c/"; // 指定臨時生成的網(wǎng)站目錄

$tpl->config_dir = __SITE_ROOT . "/configs/"; // 指定配置文件目錄

$tpl->cache_dir = __SITE_ROOT . "/cache/"; // 指定緩存目錄,這個目錄里面放著最終顯示的網(wǎng)站php 文件

$tpl->left_delimiter = '

$tpl->right_delimiter = '}>';

?>

// 創(chuàng)建一些文件夾

mkdir templates templates_c configs cache

// 編寫模板

// vim templates/test.htm

// index.php 調(diào)用該模板

// vim index.php

require "main.php";

$tpl->assign("title", "test");

$tpl->assign("content", "test_1");

// 上面兩行也可以用這行代替

// $tpl->assign(array("title" => "測試用的網(wǎng)頁標(biāo)題", "content" => "測試用的網(wǎng)頁內(nèi)容"));

$tpl->display('test.htm'); // 調(diào)用模板

?>

顯示效果:

總結(jié)

以上是生活随笔為你收集整理的php怎么安装模板_php 模板框架之smarty 的下载和安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。