thinkphp system constants and custom constants

Source: Internet
Author: User

thinkphp system constants and custom constantstime 2014-03-03 13:41:14 csdn Blog Original http://blog.csdn.net/wuji_1/article/details/20367675 Themethinkphp

----------------------------------------the system constants used in the action----------------------------------------
Think_path//thinkphp system directory
App_path//Current project directory
App_name//Current project name
Module_name//Current module name
Action_name//Current operation name
Tmpl_path//project template Catalog
Lib_path//Project Class Library Directory
Cache_path//project Template Cache Directory
Config_path//project configuration file directory
Log_path//project log file directory
Lang_path//Project Language file directory
Temp_path//Project temp file directory
Plugin_path//project plug-in file directory
Vendor_path//third-party class library Directory
Data_path//Project data file directory
Is_apache//Whether it belongs to APACHE
Is_iis//Whether it belongs to IIS
Is_win//Whether it belongs to the Windows environment
Is_linux//Whether it belongs to LINUX environment
IS_FREEBSD//Whether it belongs to FREEBSD environment
Now_time//Current timestamp
MEMORY_LIMIT_ON//Whether there is a memory usage limit
OUTPUT_GZIP_ON//whether to turn on output compression
MAGIC_QUOTES_GPC//MAGIC_QUOTES_GPC
Think_version//thinkphp Version number
Lang_set//Browser language
Template_name//Current template name
Template_path//Current template path
__root__//Website root directory Address
__APP__//Current project (entry file) address
__URL__//Current module address
__ACTION__//Current operating address
__self__//Current URL address
Tmpl_file_name//Default template name for the current operation (with path)
Web_public_url//Website Public directory
App_public_url//Project Common template Catalog
---------------------------------------- The system constants used in the template----------------------------------------
__root__//Website root directory Address
__APP__//Current project (entry file) address
__URL__//Current module address
__ACTION__//Current operating address
__self__//Current URL address
__PUBLIC__//Website Public directory
.. /public (case-insensitive)//project Common template Catalog
Note: When we use constants, after the template is loaded in the browser to view the source code, we observe some use the constant URL, we will find a phenomenon, do not see the IP address of the server, the URL is from the item
When the name starts, why does it have access to the appropriate controller? Actually this is the browser to give us a joke, when we move the mouse to the URL, right-click, copy the source of the
URL, paste to another place, the server's IP will be displayed, the visible server IP is included in the URL used in the constant.
---------------------------------------- Custom Constants----------------------------------------
Create a new common.php under the common folder in the project folder (for example: Home)
Add the following statement:
Define (' xxx ', xxx); The first argument is the constant name, the second argument is the constant value

thinkphp system constants and custom constants

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.