Home >Backend Development >PHP Tutorial >A question about thinkphp template constants.
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>
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.