In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to install and use EasyTpl in PHP", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn "how to install and use EasyTpl in PHP".
Functional characteristics
Simple, lightweight and fast.
No learning cost
Simply handle and convert to native PHP syntax
Compatible with PHP native syntax
Simpler output syntax. For example: {{= $var}} {{$var}} {{echo $var}}
All control syntax is supported. For example, if,elseif,else;foreach;for;switch
Support chained access to array values. For example: {{$arr.0}} {{$map.name}} {{$map.user.name}}
More secure, the output will be processed automatically through htmlspecialchars by default
Unless disabled or manually used raw filter
Support the use of PHP built-in functions as filters. For example: {{$var | ucfirst}}
Support for adding custom filter
Default built-in filter: upper lower nl
Support to add custom instructions and provide custom functions
Support for adding comments to the template. For example: {{# comments... #}}
Installation
PHP 8.0 + required
Composer
Composer require phppkg/easytpl Quick start use PhpPkg\ EasyTpl\ EasyTemplate;$tplCode = ['php',' go', 'java'],]; echo $str
Render output:
More instructions for using My name is INHERE,My develop tags:- php- go- java
Syntax is the same as PHP native templates, and special syntax is added just to make it easier to use.
EasyTemplate enables output filtering by default, which can be used to render view templates
TextTemplate turns off output filtering, which is mainly used for text processing, code generation, etc.
Configuration settings use PhpPkg\ EasyTpl\ EasyTemplate;$t = EasyTemplate::new (['tplDir' = >' path/to/templates', 'allowExt' = > [' .php', '.tpl'],]); / / do something.
More settings:
/ * * @ var PhpPkg\ EasyTpl\ EasyTemplate $t * / $t-> disableEchoFilter (); $t-> addFilter ($name, $filterFn); $t-> addFilters ([]); $t-> addDirective ($name, $handler); output variable value
The following statements can be used to print out the value of a variable
{{$name}} {{= $name}} {{echo $name}}
More:
{{$name?: 'inhere'}} {{$age > 20?' 20':''. $name. $body;})
Use in templates:
{{include ('part/header.tpl', [' title' = >'My world'])}} these are all the contents of the article "how to install and use EasyTpl in PHP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.