Smarty simple Getting started instance, smarty instance _ PHP Tutorial

Source: Internet
Author: User
Smarty simple entry instance, smarty instance. Smarty simple Getting started instance. smarty instance this article uses a simple instance to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows: smarty creates a configuration file and displays the smarty simple entry instance and smarty instance

This article uses a simple example to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows:

After smarty creates a configuration file and a display file, the configuration file display file is separated, so that the artist and the development work can be perfectly separated.

Configuration page code: index. php

The code is as follows:

<? Php
@ 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", "eat", "dream", "Liangfeng "));
$ My-> display('kk.html '); // Display kk.html in the smartydirectory
?>


Kk.html

The code is as follows:





Untitled Document


{$ Content}
{Section name = truelife loop = $ mylife}
{$ Mylife [truelife]}
{/Section}

I hope this article will help you design your smarty program.

This article uses a simple example to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows: smarty creates a configuration file and displays it...

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.