PHP won't include files properly since updating to Mojave On our office Mac, we have a local Apache server running through the software AMPPS. Prior to updating to Mojave, everything was working correctly. Now, after updating, there is an issue with using PHP include or require.

Our system uses an object for storing settings, and one of these is the document root path. This value is usually the same as $_SERVER['DOCUMENT_ROOT'], however using that is not an option for various reasons.

An example of the issue that is occurring:

include settings::$documentRoot . '/fileToInclude.php';


This will resolve to the path "/Applications/AMPPS/www/fileToInclude.php" and will fail with the standard 'not found' error:

Failed to open stream: No such file or directory


However, if I change the include line to the following:

include $_SERVER['DOCUMENT_ROOT'] . '/fileToInclude.php';


which resolves to the path "/Applications/AMPPS/www/fileToInclude.php" it will work without a problem.

As you can see, both include statements resolve to the exact same path, but only one works. I have done testing to confirm that both paths match exactly using a strict equality check (===).

Does anyone have any idea why this would happen in Mojave? As I mentioned, it was working perfectly fine in High Sierra, and it works fine on all our Windows machines.

EDIT:
The server error logs output the following when trying to use the failing include.

PHP Warning: include(/Applications\xe2\x81\xa9/AMPPS\xe2\x81\xa9/www/fileToInclude.php): failed to open stream: No such file or directory in /Applications/AMPPS/www/index.php on line 14
I would sanitize your input files for non printable Unicode characters. This appears to be something common when crossing platforms or using code editors that don’t show you this clearly. 


https://stackoverflow.com/questions/55841767/unable-to-display-image-using-matplotlib-pyplot-on-ipython-project
https://stackoverflow.com/questions/53016584/python-no-such-file-or-directory-error-trying-to-print-a-file-list-directory-on


What's happening looks to be different handling of text encoding - the log statement is hiding characters that the program is passing as a legitimate path in the filesystem.

It’s lucky this worked before on older OS, but the error is pointing out that you don't have /Applications\xe2\x81\xa9/AMPPS as a path and instead need your web code / framework to be looking at /Applications/AMPPS

It would be curious if all of these come from copying and pasting from the get info box and then the text editor where those values are pasting take the styled text and not the plain text version of the clipboard contents.