thinkphp Template Engine Usage Example _php instance

Source: Internet
Author: User
Tags php template codeigniter zend framework

The examples in this article describe the thinkphp template engine usage. Share to everyone for your reference, specific as follows:

1.if

<if condition= "$vo. Business eq LS" >
  retail
  <elseif condition= "$vo. Business eq CY"/>
  Catering
  < else/>
  other
</if>

After compiling

<?php
if ($vo ["business"] = LS):
?> retail
<?php
elseif ($vo ["business"] = CY):
?> Catering
<?php
Else:
?> other <?php
endif;
? >

2. Using functions

{sh: $vo. Time|default=time () |date= ' y-m-d h:i:s ', ###}

After compiling

<?php Echo (' y-m-d h:i:s ', ($vo [Time])? ( $vo ["Time"]): Time ());?>

Usually the first parameter of a function is the return result of the previous variable or previous function call, and if your variable is not the first argument of the function, you need to use the anchor symbol, for example:

{$create _time|date= "y-m-d", ###}

After compiling

<?php Echo (Date ("y-m-d", $create _time));?>

3. Default value

{$user. nickname|default= "This guy is lazy, he left nothing."}

After compiling

<?php Echo ($user ["nickname"])? ($user ["nickname"]): ' This guy is lazy, he left nothing ';?>

More interested readers of thinkphp related content can view the website topic: "thinkphp Introductory Course", "thinkphp template Operation Skill Summary", "thinkphp Common Method Summary", "The CodeIgniter Introductory Course", "CI ( CodeIgniter) Framework Advanced tutorials, introductory tutorials for the Zend framework Framework, Smarty Templates Primer tutorial, and PHP template technology summary.

I hope this article will help you with the PHP program design based on thinkphp framework.

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.