search
Homephp教程php手册thinkphp3.2官方模版标签扩展

让模版支持{if}{elseif}{else}{/if}{for}{/for}{loop}{/loop}类型的标签
刚刚使用thinkphp开发,在嵌入模版时差点被内置标签快疯了,虽然很强大,但是太繁琐,所以自己本着简单实用的原则新加了几个标签,方便自己使用,这里贡献出来方便大家

使用方法:
条件判断{if *} * {else} * {/if} <br> 或 {if *} * {elseif *} * {else} * {/if} <br> 或 {if *} * {/if}<br> 其中{if *}中的*就是此判断语句的条件表达式,符合php的表达式。<br> 例子:<br> {if !empty($c) || $a>10 && $b {$c}<br> {elseif $a>10}<br> {$a}<br> {else}<br> {$b}<br> {/if}foreach遍历{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop}<br> 例子:<br> {loop $a $b $c}<br> 第{$n}条:{$b}=>{$c}<br> {/loop}for循环 {for $i=0;$i<b>自增、自减例如</b> <code class="prettyprint linenums lang-php">自减 {$i--}  {--$i}  自增 {$i++} {++$i}单行PHP解析语法 {php $i=1;}解析为:<?php $i=1;?> <br> {php $string = date('Y-m-d');} 解析为:<?php $string = date(&#039;Y-m-d&#039;);?>添加方法:
这个是使用行为扩展添加,不知道什么是行为扩展的移步手册
1.将附件中的文件放在项目Common\Behavior文件夹中
2.行为定义配置:'template_filter'=>array('Common\\Behavior\\SimpleTemplate')3.2.1行为定义配置有变化代码为:'template_filter'=>array('Common\\Behavior\\SimpleTemplateBehavior')3.在项目配置文件中加入启用标识:'STPL_SWITCH_ON'=>TRUE该代码是从phpcms中扒出来的

附件 SimpleTemplateBehavior.class.rar ( 765 B 下载:85 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.