The role of Directory_separator in PHP _php tutorials

Source: Internet
Author: User

The role of Directory_separator in PHP



Directory_separator is the internal constant of PHP, which is used to display the system delimiter commands without any definition or inclusion.

Under Windows, the path delimiter is \ (or, of course, on some systems), the delimiter on Linux is/, which causes a problem, such as the development machine is windows, there is a picture upload program, the debug machine on the specified upload file save directory is:

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

Debugging on-premises is normal, but when uploading to a Linux server, you will see an error. So PHP introduced the directory_separator variable, you can rewrite the above syntax:

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

Directory_separator is a PHP built-in command that returns the path delimiter associated with the operating system, returns \ on Windows, and returns on Linux or Unix--that's the difference, This is usually used when you define a file path or upload a directory to save it.
For example:

View Plaincopy to Clipboardprint?
Const DIR_SEP = directory_separator;//Path segmentation win under Linux/
Private Function __construct ()
{
$this->_options = Array (
Template_dir = templates. Self::D ir_sep,//directory where template files are located
Cache_dir = templates. Self::D ir_sep. Cache. Self::D ir_sep,//cache file storage Directory
Auto_update = False, if the cache is regenerated when the template file changes
Cache_lifetime = 0,//Cache life cycle (minutes), 0 for permanent
suffix =. html//template file suffix
);
}

http://www.bkjia.com/PHPjc/905602.html www.bkjia.com true http://www.bkjia.com/PHPjc/905602.html techarticle PHP's role in Directory_separator directory_separator is the internal constant of PHP, which is used to display the system delimiter command, without any definition and inclusion to be used directly. Under Windows ...

  • 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.