: This article mainly introduces the smarty allocation variables of php. if you are interested in the PHP Tutorial, refer to them. Smarty2.php
Require('Smarty/Smarty. class. php ');Require'. /Smarty. inc. php '; global $ _ smarty; $ _ title = 'smarty template engine'; $ _ Smarty-> assign ('title', $ _ title ); $ _ array = array ('AAA', 'bbbbbb', 'CCC ', 'ddddd'); $ _ array2 = array ('hahaha' => 'AAA ', 'hei' => 'bbbb', 'Lala '=> 'CCC', 'xixi' => 'ddddd'); $ _ array3 = array ('hahaha ', 'sss'), array ('Lala ', 'ssdvs'), array ('ewef', 'wefwa ')); $ _ array4 = array ('AAA' => array ('hahaha', 'sss'), 'BB' => array ('Lala ', 'ssdvs '), 'CC' => array ('ewe F', 'wefwa '); class People {public $ _ name = 'nini'; public function _ run () {return 'running .... ';}}; $ _ smarty-> assign ('array', $ _ array); $ _ smarty-> assign ('array2', $ _ array2 ); $ _ smarty-> assign ('array3', $ _ array3); $ _ smarty-> assign ('array4', $ _ array4 ); $ _ smarty-> assign ('people', new people (); $ _ smarty-> display ('demo2. tpl '); // phpinfo ();?>
Demo2.tpl
{config_load file='webconfig.config'} {$title} hi,{$name} Welcome to website!!!
{$array[2]}
{$array2.hehe}
{$array3[2][0]}
{$array4.bb[1]}
{$people->_name}{$people->_run()}
{$smarty.config.webname}{#weburl#}
{$smarty.get.name}
Access address: http: // 127.0.0.1/smarty2.php? Name = hahahahaha
The above describes the smarty allocation variables of php, including The require content, and hope to be helpful to friends who are interested in PHP tutorials.