How PHP converts file name capitalization from the operating system

Source: Internet
Author: User
Tags php file require

This article mainly introduces PHP based on the operating system to convert file name case method, the need for friends can refer to the

In the development of PHP we want to include a file The usual code is this: the code is as follows: <?php if (Is_file ($fileName)) require $flleName; Running under Windows,linux does not ask a question: Suppose you want to include a d:/web/webserver/a.php file at the time of the value of the message d:/web/webserver/a.php when running under Windows will also d:/web/ Webserver/a.php is included because Windows is not case-sensitive, and it will be wrong if you put it on Linux. Is it possible to be case-sensitive when loading Windows? The code is as follows: if (Is_file ($fileName)) {//php_os currently running operating system if (STRSTR (Php_os, ' WIN ')) {//realpath ($fileName) converts             The case of the filename/web/a.php if a.php does not exist and a.php returns/web/a.php if (basename ($fileName) = = Realpath ($fileName))         Require $fileName;     else echo ' Please check the case of file '; }else require $fileName; }

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.