0

I have project work in localhost my operator

MacOs sierra 10.12.5
Install Ampps sever version 3.6
Apache/2.4.25
PHP 5.6.30

i have a folder with path /Applications/AMPPS/www/project/library/Utilities/Path.php

php

var_dump(is_file('/Applications/AMPPS/www/project/library/utilities/path.php'));

alway return true but when i move to live hosting with operation

Ubuntu 14.04.5 LTS
PHP 5.6.30-12~ubuntu14.04.1+deb.sury.org+1 (cli) 
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jul 15 2016 15:34:04

and the path is different like /username/www/project/library/Utilities/Path.php

php

var_dump(is_file('/username/www/project/library/utilities/path.php'))

alway return false

i mean in my localhost the php function is_file or file_exits alway return true with filename or file folder first character is uppercase but in live host this alway return false , what different in this case ?

Peter Jack
  • 847
  • 5
  • 14
  • 29

1 Answers1

0

The difference is that one file system is case sensitive and one isn't.

In Mac OS your default file system is HFS+ where file names are not case sensitive, so foo.php and Foo.php are treated as equals.

In Ubuntu your default file system is (probably) ext4 where file names are case sensitive, so foo.php and Foo.php are different files and can even co-exist in the same directory.

(Note: this applies to file and folder names, so /foo/bar.php and /Foo/bar.php could also be equals in one and not equals in the other)

I can see basically three options:

  1. The best solution would be to always use (or require) the correct case for file and directory names.

  2. If you absolutely need to deal with different/potentially incorrect cases, you might get away with an own solution (e.g. PHP Case Insensitive Version of file_exists(); basically: list all files in a directory and manually compare them). But in this case, would you load foo.php or Foo.php or foO.php when FOO.php is required and all three files exist?

  3. If you have the necessary rights you could set up your Ubuntu to use a different file system where file names are case insensitive as well. Expect wry looks from linux guys.

Marvin
  • 13,325
  • 3
  • 51
  • 57