Use native PHP code in the thinkphp tutorial template ____php

Source: Internet
Author: User

tmpl_deny_php this argument to false try the config file

' tmpl_deny_php ' => false,///The default template engine disables PHP native code

PHP code can be mixed with tags in template files, you can write arbitrary PHP statement code in the template file, including the following two ways:
The first is the use of PHP Tags:


For example:  
<php>echo ' hello,world! '; </PHP>&NBSP
We recommend that you use PHP tags as much as possible when using PHP code, because native PHP syntax may be configured to disable and cause parsing errors. &NBSP
The second way is to use the original PHP code directly:  

<?php echo ' hello,world! ';? > 

Note: tags (including regular tags and XML tags) can no longer be used in PHP tags or php code, so the following methods are not valid:  

<php><eq name= ' name ' value= ' Value ' >value</eq></php> 

The EQ tag is used inside the PHP tag, so it is invalid  

<php>if ({$user}!= ' thinkphp ') echo ' thinkphp '; </php> 



PHP tag uses the {$user} normal label output variable and is therefore invalid. &NBSP

<php>if ($user. Name!= ' thinkphp ') echo ' thinkphp '; </php> 

PHP tag uses $ User.Name point syntax variable output, therefore invalid. &NBSP
In short, the PHP tag does not use code that is not supported by PHP itself. &NBSP
If the tmpl_deny_php parameter is set to True, native PHP code cannot be used in the template, but PHP tag output is still supported.  

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.