Home > Backend Development > PHP Tutorial > A question about thinkphp template constants.

A question about thinkphp template constants.

WBOY
Release: 2016-09-08 08:44:01
Original
1009 people have browsed it

The manual says: By default, template replacement will only replace the special strings in the template file and will not replace the output content in the dynamic data.

But I can print the template constant __SELF__ in the php file. Why is this? Don't quite understand this principle. .

<code><?php 
public function add(){
        var_dump(__SELF__); //输出string '/Home/Order/add.html' (length=20)
}
?></code>
Copy after login
Copy after login

Reply content:

The manual says: By default, template replacement will only replace the special strings in the template file and will not replace the output content in the dynamic data.

But I can print the template constant __SELF__ in the php file. Why is this? Don't quite understand this principle. .

<code><?php 
public function add(){
        var_dump(__SELF__); //输出string '/Home/Order/add.html' (length=20)
}
?></code>
Copy after login
Copy after login

Of course it can be printed. Is there anything you don’t understand

The __self__ here is used as a magic constant. Try printing __public__ and see if you can print something

It seems that TP has not blocked the __self__ magic constant, so it can be printed

There seem to be two types of PHP variables, one with $ and one without $. The assignment is declared through defined('_PHP_FILE_', 'aaa'). The two variables are similar.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template