thinkphp file Reference and branch structure usage instance _php instance

Source: Internet
Author: User

This example describes the use of thinkphp file references and branching structures. Share to everyone for your reference. The specific analysis is as follows:

First, import CSS and JS files

1, CSS Link:

Copy Code code as follows:
<link rel= ' stylesheet ' type= ' text/css ' href= ' __public__/css/test.css '

JS SRC:

Copy Code code as follows:
<script src= ' __public__/js/test.js ' ></script>

2. Import

Copy Code code as follows:
<import type= ' js ' file= ' js.test '/>//Import the Test.js file in the JS directory below the public folder, the import tag can omit the type attribute, and the default is JS
<import type= ' css ' file= ' css.test '/>//default is public folder
You can change the default folder settings BasePath properties
<import type= ' js ' file= ' js.my ' basepath= './other '/>

3. Load

Copy Code code as follows:
method to automatically detect an imported file type
<load href= ' __public__/js/test.js '/>

Second, the branch structure

1, if

Copy Code code as follows:
<if condition= ' $sex eq ' man ' >
Men are made of mud.
<else/>
Women are made of water.
</if>

<if condition= ' $age lt ' >
Minor
<elseif condition= ' $age eq '/>
Age
<else/>
Adult
</if>


Add:
> GT
< LTLT
= = EQ
<= ELT
>= EGT
!= NEQ
= = = Heq
!== Nheq

2. Switch

Copy Code code as follows:
<switch name= ' number ' >//loop to remove the $ symbol from the variable
<case value= ' 1 ' > a monk fetching water to eat </case>
<case value= ' 2 ' > Two monk table water eat </case>
<case value= ' 3 ' > Three monks have no water to eat </case>
<default/> This is the default value
</switch>

I hope this article will be helpful to everyone's thinkphp framework program design.

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.