$file=file('DATA.txt');
I keep getting "failed to open stream. No such file or directory in ...". This works when I run it on a server and browser. But the error occurs when I run the script using command line.
$file=file('DATA.txt');
I keep getting "failed to open stream. No such file or directory in ...". This works when I run it on a server and browser. But the error occurs when I run the script using command line.
First of all take a deep breath and a tea ;)
The news is: DATA.txt
is only a file-name.
A file normally is placed in a directory. As stupid as this sounds, well, as stupid this is: What is the directory?
The answer: the current working directory. This differs between servers and CLI.
So better add your directory as well:
$name = 'DATA.txt';
$dir = 'C:/';
$path = $dir.$name;
$file = file($path);
Hope this is helpful.