Home >Backend Development >PHP Tutorial >Smarty simple entry examples, smarty examples_PHP tutorial

Smarty simple entry examples, smarty examples_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:49840browse

Smarty simple entry examples, smarty examples

This article analyzes the usage of smarty with a simple example. Share it with everyone for your reference. The specific analysis is as follows:

After smarty creates the configuration file and displays the file, the configuration file displays the file separately, so that the art and development work can be perfectly separated

Configuration page code: index.php

Copy code The code is as follows:
@header("Content-type: text/html; charset=UTF-8");
require '../libs/Smarty.class.php';
$my=new Smarty;
$my->template_dir ='templates/';
$my->compile_dir ='templates_c/';
$my->config_dir ='configs/';
$my->cache_dir ='cache/';

$my->assign('content','welcome to arrival');
$my->assign('mylife',array("life","eating","dream","cool breeze"));
$my->display('kk.html'); //Display kk.html in the smarty directory
?>

kk.html
Copy code The code is as follows:




Untitled Document


{$content}
{section name=truelife loop=$mylife}
{$mylife[truelife]}
{/section}

I hope this article will be helpful to everyone’s smarty programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919262.htmlTechArticlesmarty simple entry example, smarty example This article uses a simple example to analyze the usage of smarty. Share it with everyone for your reference. The specific analysis is as follows: smarty creates configuration files and displays...
Statement:
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