PHP smarty Detailed configuration

Source: Internet
Author: User

1. Download path on Smarty website: https://github.com/smarty-php/smarty/releases

2. Extract the downloaded Smarty

3. Copy the libs from the extracted smarty to the project you created.

4. Create two folders under Smarty: Templates store the template, and Templates_c store the compiled file

5. Write the following code in index.php:

<?php
Create a Smarty Object
Require_once './libs/smarty.class.php ';
Instantiating a Smarty Object
$smarty =new smarty ();
Setting variables and values
$smarty->assign ("var", "Hello World");
Apply Template file
$smarty->display ("hello.html");
?>

6. Create the corresponding hello.html file in the templates directory

The 7.hello.html file code is as follows:

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>insert title here</title>
<body>
{$var}//Introduce variable name
</body>

7. In the browser open index.php you will see Hello word!

PHP smarty Detailed configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.