Smarty Study Notes _php Tutorial

Source: Internet
Author: User
Learning PHP must not mention the Smarty, as a well-known template program, Smarty naturally has its advantages. Here is my summary of my own a little learning experience it!
=====================================
First download the latest smarty in Smarty.php.net
Put the Libs folder in your Web directory, I placed under Smarty, the directory situation is as follows: E:/smarty/libs
Create the following folder under the Smarty directory:
Templates (Here you put your template file, that is, the TPL file)
Configs
Templates_c (automatically converts the compiled files to PHP in this place)
Cache
Then build the index.php in the Wwwroot directory:
Include "smarty/libs/smarty.class.php";
Define (' __site_root ', ' e:/smarty '); There's no diagonal line.
$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 ')
?>

To create a index.tpl in the template directory:



<title>New Document</title>







hello,{$name}~.





The local index.php then displays the hello,world!~.

http://www.bkjia.com/PHPjc/317624.html www.bkjia.com true http://www.bkjia.com/PHPjc/317624.html techarticle Learning PHP must not mention the Smarty, as a well-known template program, Smarty naturally has its advantages. Here is my summary of my own a little learning experience 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.