在Mac上是否区分大小写file_exists()? [英] case sensitivity on Mac for file_exists()?

查看:334
本文介绍了在Mac上是否区分大小写file_exists()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,Mac OS X不是我的本机操作系统,但是由于我对Ubuntu感到满意,因此在大多数情况下,这是一个容易的过渡.

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.

由于它是基于Unix的,所以给我的印象是该操作系统区分大小写,但是file_exists()函数却相反.

Being that it's Unix-based, I was under the impression this os was case-sensitive, but the file_exists() function is saying otherwise.

在我的htdocs文件中,我有以下2个文件:

In my htdocs file, i have these 2 files:

test.php

MyFiLeWiThMiXeDCaSe.php

MyFiLeWiThMiXeDCaSe.php

在test.php中,我有以下代码:

In test.php, i have this code:

if(file_exists('myfilewithmixedcase.php')) {
  echo 'exists';
} else {
  echo 'doesnt exist';
}

// ouputs: exists

任何人都知道这是为什么/为什么发生的?这引起了一个问题,因为当我们将这样的代码部署到linux操作系统时,file_exists()返回的是false.

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.

顺便说一句:我正在使用MAMP PRO作为本地Web服务器.

BTW: I'm using MAMP PRO as the local web server.

推荐答案

尽管BSD衍生OS X不区分大小写.或更确切地说,不是HF和HFS +文件系统,除非在格式化磁盘时选择了区分大小写的选项.通常不会执行此操作,因为许多应用程序都存在此问题(例如Adobe,MS等),或者至少在我上一次在Tiger下尝试过时才这样做.

Despite being a BSD derivative OS X is NOT case sensitive. Or rather HFs and HFS+ filesystems are not, unless you chose the case sensitive option when formatting your disk. 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.

这篇关于在Mac上是否区分大小写file_exists()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆