For more information about PHP's Smarty learning, see the documents on the network. you can use Smarty to perform a simple test:
1. decompress the Smarty file to the website directory, such as libs.
2. create the templates, templates_c, configs, and cache directories.
3. create a test page: index. php
Require "main. php ";
// $ Tpl defined in main. php
$ Tpl-> assign ("title", "webpage title for testing ");
$ Tpl-> assign ("content", "tested webpage content ");
// The above two rows can also be replaced by this line
// $ Tpl-> assign (array ("title" => "webpage title for testing", "content" => "webpage content for testing "));
$ Tpl-> display('index.htm ');
?>
4.create the template file index.htm under templates
<{$ Title}>
<{$ Content}>
5. create main. php
/* If this addition is not added, an error is reported:
Notice: Undefined variable: _ SESSION in E: \ PHPnow-1.5.1 \ vhosts \ xxh.com \ libs \ Smarty. class. php on line 585
I don't know why
*/
Session_start (); // enable session
Include "libs/Smarty. class. php ";
Define ('_ SITE_ROOT', 'E:/PHPnow-1.5.1/vhosts/xxh.com '); // no diagonal lines at last
$ 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.