[英]case sensitivity on Mac for file_exists()?
First off, Mac OS X is not my native operating system but since I'm comfortable in Ubuntu, it's been an easy transition for the most part. 首先,Mac OS X不是我的原生操作系统,但由于我对Ubuntu很满意,所以大部分时间都是一个简单的过渡。
Being that it's Unix-based, I was under the impression this os was case-sensitive, but the file_exists()
function is saying otherwise. 由于它是基于Unix的,我觉得这个操作系统区分大小写,但
file_exists()
函数却说不然。
In my htdocs file, i have these 2 files: 在我的htdocs文件中,我有这两个文件:
test.php test.php的
MyFiLeWiThMiXeDCaSe.php MyFiLeWiThMiXeDCaSe.php
In test.php, i have this code: 在test.php中,我有这个代码:
if(file_exists('myfilewithmixedcase.php')) {
echo 'exists';
} else {
echo 'doesnt exist';
}
// ouputs: exists
Anyone know how/why this is happening? 任何人都知道这是怎么回事? This is causing a problem because when we deploy code like this to a linux OS,
file_exists()
is returning false. 这导致了一个问题,因为当我们将这样的代码部署到linux OS时,
file_exists()
返回false。
BTW: I'm using MAMP PRO as the local web server. BTW:我正在使用MAMP PRO作为本地Web服务器。
Despite being a BSD derivative OS X is NOT case sensitive. 尽管是BSD衍生OS X不是区分大小写的。 Or rather HFs and HFS+ filesystems are not, unless you chose the case sensitive option when formatting your disk.
或者更确切地说HF和HFS +文件系统不是,除非您在格式化磁盘时选择了区分大小写的选项。 This is usually not done because many applications have issues with this (Adobe, MS, etc.) - or at least they did the last time i tried it under Tiger.
这通常没有完成,因为很多应用程序都存在这方面的问题(Adobe,MS等) - 或者至少它们是我最后一次在Tiger下试用时做的。
The default filesystem on OS X is case-insensitive HFS+. OS X上的默认文件系统是不区分大小写的HFS +。
You can format a volume as case-sensitive HFS+, and there are (dirty) ways of enabling case-sensitivity for existing volumes. 您可以将卷格式化为区分大小写的HFS +,并且有(脏)方法可以为现有卷启用区分大小写。 But, these will break existing software, and you should avoid case-sensitivity on your root volume.
但是,这些将破坏现有软件,您应该避免在根卷上区分大小写。
If you need a case-sensitive filesystem for some reason (eg building Android requires it), you can make an appropriately-formatted disk image using Disk Utility. 如果出于某种原因需要区分大小写的文件系统(例如,构建Android需要它),则可以使用“磁盘工具”制作适当格式的磁盘映像。
Note that the UNIX foundation of OS X will work just fine with a case-sensitive filesystem. 请注意,OS X的UNIX基础适用于区分大小写的文件系统。
默认情况下,Mac OS X不区分大小写,因此“FILE”和“file”是同一文件的两个名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.