Predefined constants of PHP

Source: Internet
Author: User
Today, I am reading a demo of yaf of laruence. In the entry FILE, the author has the following definition: define (DS,); define (APP_PATH, dirname (_ FILE __). DS .... DS. application. DS); the author means that DS is defined as the path separator. I suddenly remember that a constant in PHP defines the path separator, And that constant is an adaptive platform.

Today, I am reading a demo of yaf of laruence. In the entry FILE, the author has a definition: define (DS,/); define (APP_PATH, dirname (_ FILE __). DS .... DS. application. DS); the author means that DS is defined as the path separator. I suddenly remember that a constant in PHP defines the path separator, And that constant is an adaptive platform.

Today, I am reading a demo of yaf of laruence. In the entry file, the author has the following definition:

define("DS", '/');define("APP_PATH", dirname(__FILE__).DS.'..'.DS.'application'.DS);
The author means "DS" is defined as the path separator. I suddenly remember that a constant in PHP defines the path separator, And that constant is an adaptive platform. The author does not need to define this definition at all, because if it is really true, we have to change it under win.

But I suddenly forgot how to spell the constant, and I am sorry to check the manual. Swollen? You can only print all the pre-defined constants using "get_defined_constants ()" and find them by yourself:

print '
';print_r(get_defined_constants());print '
';


The get_defined_constants function returns all predefined constants to an array.

Print it out. Hey, there are so many! What I want is this:
[DIRECTORY_SEPARATOR] => \[PATH_SEPARATOR] => ;

DIRECTORY_SEPARATOR, which is defined as "\" under windows;

The code can be changed:

define("DS", DIRECTORY_SEPARATOR);define("APP_PATH", dirname(__FILE__).DS.'..'.DS.'application'.DS);

As the name implies, DIRECTORY_SEPARATOR is the "directory separator" and directory separator.

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.