Php codes and labels can be mixed in the template file, you can write any statements in the template file inside PHP code, including the following two ways:
The first: use php tags
E.g:
<php>echo 'Hello,world!';</php>
We recommend using PHP code when needed to maximize the use php tags because native PHP syntax may be configured to disable a result of parsing errors.
The second: use native php code
<?php echo 'Hello,world!'; ?>
Note: php php code label or tag which no longer be used (including ordinary XML tags and labels), so the following ways are valid:
<php><eq name='name'value='value'>value</eq></php>
Php label which uses the eq
label, and therefore invalid
<php>if( {$user} != 'ThinkPHP' ) echo 'ThinkPHP' ;</php>
Php label which uses a {$user}
normal label output variables, and therefore invalid.
<php>if( $user.name != 'ThinkPHP' ) echo 'ThinkPHP' ;</php>
Php label inside using $user.name
dot syntax output variable, and therefore invalid.
In short, you can no longer use the code in PHP itself does not support PHP tags inside.
If you set the TMPL_DENY_PHP
parameter to true, you can not use the native PHP code in the template, but still supports PHP tag output.