How PHP converts file name capitalization from the operating system

Source: Internet
Author: User
Tags php file

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; }
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.