Home > Backend Development > PHP Tutorial > PHP simple smarty entry program example, smarty entry example_PHP tutorial

PHP simple smarty entry program example, smarty entry example_PHP tutorial

WBOY
Release: 2016-07-13 09:50:54
Original
930 people have browsed it

php simple smarty entry program example, smarty entry example

The example in this article tells the php simple smarty entry program. Share it with everyone for your reference. The details are as follows:

First there are 3 folders configs, templates, templates_c. There is a configuration file in the configs folder: test.conf, code:

title = Welcome to Smarty!
cutoff_size = 40
[setup]
bold = true

Copy after login

There is a template file in templates: test.htm:

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, {$Name}</H1> 
  </body> 
</html> 

Copy after login

php file code:

<&#63;php 
require 'libs/Smarty.class.php'; //包含Smarty类库文件 
$smarty = new Smarty; //创建一个新的Smarty对象 
$smarty->assign("Name","Simon"); //对模版中的变量赋值 
$smarty->display('test.htm'); //显示页面 
&#63;>
Copy after login

The page code displayed after running:

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, Simon</H1> 
  </body> 
</html> 

Copy after login

After running, a php file is also generated in the templates_c folder:

<&#63;php
/* Smarty version 2.6.22, created on 2009-03-19 13:20:00 
     compiled from test.htm */
&#63;> 
<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, <&#63;php echo $this->_tpl_vars['Name']; &#63;> 
</H1> 
  </body> 
</html> 

Copy after login

This file is the effect displayed when browsing.

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1015434.htmlTechArticlephp simple smarty entry program example, smarty entry example This article tells the php simple smarty entry program example. Share it with everyone for your reference. The details are as follows: First, there must be 3 folders...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template