Home >Backend Development >PHP Tutorial >SMARTY Learning Notes_PHP Tutorial

SMARTY Learning Notes_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:58:10850browse

You cannot learn PHP without mentioning SMARTY. As a famous template program, SMARTY naturally has its advantages. Below is a summary of my own learning experience!
=================================
first at Smarty.php.net Download the latest smarty
Put the libs folder in your WEB directory. I placed it under smarty. The directory is as follows: e:/smarty/libs
Create the following folder in the smarty directory:
templates (put your template files here, that is, tpl files)
configs
templates_c (automatically convert the compiled files into PHP and put them here)
cache
Then create index in the wwwroot directory .php:
include "smarty/libs/Smarty.class.php";
define('__SITE_ROOT', 'e:/smarty'); // No slash at the end
$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 = '<{'; Can be changed as needed.
//$tpl->right_delimiter = '}>';
$tpl->assign('name','world!');
$tpl->display('index .tpl')
?>

Create index.tpl in the template directory:


New Document







hello,{$name}~.





Then the local index.php displays hello, world!~.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317624.htmlTechArticleYou cannot learn PHP without mentioning SMARTY. As a famous template program, SMARTY naturally has its advantages. Below is a summary of my own learning experience! ==============...
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