Directory in PHP

Source: Internet
Author: User
Tags define linux


Directory_separator is the internal constant of PHP, used to display the system separator commands, without any definition or inclusion to be used directly.

In Windows under the path separator is \ (of course/on the part of the system can also be normal operation), on Linux, the path of the separator is/, which led to a problem, such as the development of the machine is Windows, there is a picture upload program, debug machine designated upload file save directory is:

Define (ROOT, DirName (__file__). " /upload ");

Debugging locally is normal, but when uploaded to a Linux server, you will find an error. So PHP introduced the directory_separator variable, you can rewrite the above to:

Define (ROOT, DirName (__file__). Directory_separator. " Upload ");

Directory_separator is a PHP built-in command that returns the path separator associated with the operating system, returned on Windows, and returns on Linux or Unix-like, that's the difference. It is usually used when defining the include file path or uploading the save directory.
For example:

View Plaincopy to Clipboardprint?
Const DIR_SEP = directory_separator;//path split win under Linux/
Private Function __construct ()
{
$this->_options = Array (
Template_dir => templates. Self::D ir_sep,//template file directory
Cache_dir => templates. Self::D ir_sep. Cache. Self::D ir_sep,//cache file storage Directory
Auto_update => false,//rebuild cache when template files are changed
Cache_lifetime => 0,//Cache life cycle (minutes), 0 for permanent
Suffix =>. html//template file suffix
);
}



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.