The Thinkphp template engine can directly output some system variables, system constants, and system special variables without assigning a value to a template variable. The output of system variables must start with $Think. and can still support the use of functions. Let’s share them separately.
(1) System variables : Output system variables in the template: including server, env, session, post, get, request, cookie
{$Think.server.script_name} // Output $_SERVER variable
{$Think.session.session_id|md5} // Output $_SESSION variable
{$Think.get.pageNumber} // Output $_GET variable
{$Think.cookie.name} // Output $_COOKIE variable
The above method can also be written as:
{$_SERVER.script_name} // Output $_SERVER variable
{$_SESSION.session_id|md5} // Output $_SESSION variable
{$_GET.pageNumber} // Output $_GET variable
{$_COOKIE.name} // Output $_COOKIE variable
System constants: Use $Think.const to output
Note: server, cookie, and config are not case-sensitive, but variables are case-sensitive. For example:
{$Think.server.script_name} and {$Think.SERVER.script_name} are equivalent
SESSION and COOKIE also support the output of two-dimensional arrays
For example:
{$Think.CONFIG.user.user_name}
{$Think.session.user.user_name}
The system does not support array output of more than three dimensions.
(2) Language variable : Output the current language definition value of the project
{$Think.lang.page_error}
{$Think.const.MODULE_NAME}
or use directly
{$Think.MODULE_NAME}
(3) Special variables : Constants defined internally by the ThinkPHP system
{$Think.version} //Version
{$Think.now} //Now time
{$Think.template|basename} //Template page
{$Think.LDELIM} //Template label starting symbol
{$Think.RDELIM} //Template tag end symbol
(4) Configuration parameter : Output the configuration parameter value of the project
{$Think.config.db_charset}
The output value is the same as the result of C('db_charset').
(5) thinkphp system constants (note that the following constants can also be used directly in the action controller)
__ROOT__ // Website root directory address
__APP__ // Current project (entry file) address
__URL__ // Current module address
__ACTION__ // Current operation address
__SELF__ // Current URL address
__PUBLIC__ // Website public directory