Use of variables in thinkphp templates

Source: Internet
Author: User

one, variable output
1. Scalar output (normal)
2. Array output
{$name [1]}
{$name [' K2 ']}
{$name. K1}

$arr = Array (' a1 ' = ' and ' appropriate ', ' a2 ' = ' comfort point ');
$this->assign ($arr); Pass the entire array directly without assigning values, using the array's subscript as the name directly in the template
<{$a 1}>//= and can be properly
3. Object output
How to introduce a third-party class file
New folder under 1.www\think\thinkphp\extend\library\org folder Test
2. New Test.class.php
3.import (' ORG. Test.test ');
4.new Test
$obj = new Test ();
$this->assign (' obj ', $obj);

{$obj: k}
{$obj->k}
second, System variablesCookie session Get ... Manual, template engine, System variables
{$Think. Get.id}
iii. use of functions
{$name |strtoupper} generated the compiled file is <?php Echo (Strtoupper ($name));?>
{$name |date= ' Y m D h:i:s ', # # #}
Four, default value
{$name |default= ' here is the default value '}
v. Operators
+ - * / % ++ --
{$name + +}

Use of variables in thinkphp templates

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.