Role of DIRECTORY_SEPARATOR-PHP Tutorial

Source: Internet
Author: User
Role of DIRECTORY_SEPARATOR. DIRECTORY_SEPARATOR is an internal constant of php. it is used to display system separator commands and can be directly used without any definition or inclusion. In windows, the path separator is (of course, some DIRECTORY_SEPARATOR is the internal constant of php, which is used to display the system separator command and can be directly used without any definition or inclusion.

In windows, the path separator is (of course, it can also run normally on some systems). In linux, the path separator is/, which leads to a problem, for example, if the development machine is windows and there is an image upload program, the directory for storing the specified Upload files on the debugging machine is:

Define (ROOT, dirname (_ FILE _). "/upload ");

Local debugging is normal, but errors may occur when uploaded to the linux server. So php introduced the DIRECTORY_SEPARATOR variable, which can be rewritten:

Define (ROOT, dirname (_ FILE _). DIRECTORY_SEPARATOR. "upload ");

DIRECTORY_SEPARATOR is a php built-in command that returns path delimiters related to the operating system. it is returned on windows, while/is returned on linux or unix-like, it is usually used when defining the path containing files or uploading and storing directories.


For example:

View plaincopy to clipboardprint?
Const DIR_SEP = DIRECTORY_SEPARATOR; // path separation in Windows/
Private function _ construct ()
{
$ This-> _ options = array (
Template_dir => templates. self: DIR_SEP, // directory where the template file is located
Cache_dir => templates. self: DIR_SEP. cache. self: DIR_SEP, // cache file storage directory
Auto_update => false, // whether to regenerate the cache when the template file is changed
Cache_lifetime => 0, // cache lifecycle (minutes), 0 indicates permanent
Suffix =>. html // template file suffix
);
}

Bytes. In windows, the path separator is (of course/in some...

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.