Php smarty allocation variable

Source: Internet
Author: User
: 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.

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.