I have to read the contents of a file with a single quote ('
) in the file name. I have no influence on the file name, so renaming is not an option. Unfortunately, simply escaping it doesn't work, as in:
$myFile = 'John\\\'s file';
$text = file_get_contents($myFile);
What would be the correct way to access this file in PHP 5 on a Linux system?
You don't need to double-escape your string:
I've just tried a similar command on my terminal:
It works.