Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the T method in thinkphp

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the T method in thinkphp". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the T method in thinkphp.

In thinkphp, the T method is used to generate the template file name with the syntax "T ([resource: / /] [module @] [topic /] [controller /] operation, [view layering])". The return value of this method is a complete template file name, which can be directly used for rendering output by display and fetch methods.

The operating environment of this tutorial: Windows7 system, thinkphp v5.1, Dell G3 computer.

To make it easier to output template files, thinkphp encapsulates a T function to generate template file names.

Usage:

T ([resource: / /] [module @] [topic /] [controller /] operation, [view layering])

The return value of the T function is a complete template file name that can be directly used for rendering output by the display and fetch methods.

For example:

T ('Public/menu'); / return current module / View/Public/menu.html T (' blue/Public/menu'); / / return current module / View/blue/Public/menu.html T ('Public/menu','Tpl'); / / return current module / Tpl/Public/menu.html T (' Public/menu') / / return current module / Tpl/Public_menu.html T ('Public/menu') if TMPL_FILE_DEPR is _; / return current module / Tpl/Public/menu.tpl T (' Admin@Public/menu') if TMPL_TEMPLATE_SUFFIX is .tpl; / / return Admin/View/Public/menu.html T ('Extend://Admin@Public/menu') / / return Extend/Admin/View/Public/menu.html (the Extend directory depends on the configuration in AUTOLOAD_NAMESPACE)

Use the T function directly in the display method:

/ / use T function to output template $this- > display (T ('Admin@Public/menu'))

The T function can output different view hierarchical templates.

At this point, I believe you have a deeper understanding of "how to use the T method in thinkphp". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report