PHP Smarty Learning

Source: Internet
Author: User
Refer to the data on the network, using Smarty can be easily tested:

1. Unzip the Smarty to the site directory, such as the name Libs.

2. Create a Templates,templates_c,configs,cache directory

3. Build test page: index.php

Require "main.php";

$tpl defined in main.php


$tpl->assign ("title", "page title for Testing");
$tpl->assign ("content", "contents of test pages");
The above two lines can also be used instead of this line
$tpl->assign ("title" + "test page title", "Content" and "content" = "test page contents"));
$tpl->display (' index.htm ');
?>

4. Create a template file under Templates index.htm


  
  
  <{$title}>
  
  
<{$content}>
  
  

5. Establish main.php

/* Below this plus if no error is reported:

notice:undefined variable: _session in E:\PHPnow-1.5.1\vhosts\xxh.com\libs\Smarty.class.php on line 585

Don't know why

*/
Session_Start ();//Open session
Include "libs/smarty.class.php";
Define (' __site_root ', ' e:/phpnow-1.5.1/vhosts/xxh.com '); 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 = ' <{';
$tpl->right_delimiter = '}> ';
?>

6. Open index.php to test the smarty.

  • 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.