Home  >  Article  >  Backend Development  >  A question about thinkphp template constants.

A question about thinkphp template constants.

WBOY
WBOYOriginal
2016-09-08 08:44:01921browse

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>

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>

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.

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