This article briefly describes Smarty’s template variable output method. Share it with everyone for your reference, the details are as follows:
config.inc.php configuration file is as follows:
include_once('smarty/Smarty.class.php'); $smarty=new Smarty(); $smarty->config_dir="smarty/Config_File.class.php"; $smarty->caching=false; //是否開啟緩存 $smarty->template_dir="./templates"; //模板目錄 $smarty->compile_dir="./templates_c"; //編譯目錄 $smarty->cache_dir="./smarty_cache"; //緩存目錄 $smarty->left_delimiter="<{"; $smarty->right_delimiter="}>";
index.php file is as follows:
include('./config.inc.php'); $title="php測(cè)試標(biāo)題"; $content="smarty練習(xí)!"; $newstext[]=array("name"=>"php程序測(cè)試","date"=>"2015-08-01"); $newstext[]=array("name"=>"php視頻教程","date"=>"2015-08-02"); $newstext[]=array("name"=>"smarty學(xué)習(xí)","date"=>"2015-08-03"); $row=array("標(biāo)題","姓名","年齡"); $smarty->assign("title",$title); $smarty->assign("row",$row);//一個(gè)數(shù)組傳遞多個(gè)值 $smarty->assign("shownewstext",$newstext);//二維數(shù)組傳遞多個(gè)值 $smarty->assign("content",$content); $smarty->display('index.htm');
The running results are as follows:
測(cè)試數(shù)組:標(biāo)題 | 姓名 | 年齡 -------------------------------------------------------------------------------- 測(cè)試內(nèi)容為:smarty練習(xí)! 循環(huán)新聞內(nèi)容為: php程序測(cè)試 - 2015-08-01 php視頻教程 - 2015-08-02 smarty學(xué)習(xí) - 2015-08-03
## I hope that this article will be helpful to everyone based on Smarty Template PHP programming can be helpful. For more smarty simple template variable output methods, please pay attention to the PHP Chinese website for related articles!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Guide: Stellar Blade Save File Location/Save File Lost/Not Saving
4 weeks ago
By DDD
Oguri Cap Build Guide | A Pretty Derby Musume
2 weeks ago
By Jack chen
Agnes Tachyon Build Guide | A Pretty Derby Musume
2 weeks ago
By Jack chen
Dune: Awakening - Advanced Planetologist Quest Walkthrough
4 weeks ago
By Jack chen
Date Everything: Dirk And Harper Relationship Guide
4 weeks ago
By Jack chen

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
