I want to get the content in a text file and I am using file_get_contents()
But problem starts when I try to read files having white space into the file name.
for example: /home/project/text cv.txt
cannot be read using file_get_contents()
.
Is there any alternative to read .txt files ?
Another option would be to use realpath() to wrap the URI to your file:
$path = realpath( dirname(__FILE__).'/../_files/file with space.txt' );
$data = file_get_contents($path);
There is a hint in the documentation: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().
try file_get_contents(text cv);
or file_get_contents(text%20cv);