As part of application logging, I'm attempting to open a local file, and if that file doesn't already exist, to create the new one. Here's what I have:
$path = '/home/www/phpapp/logs/myawesome_logfile.txt';
$f = (file_exists($path))? fopen($path, "a+") : fopen($path, "w+");
fwrite($f, $msg);
fclose($f);
chmod($path, 0777);
I've double-checked, and the /logs directory is chmod 0777, and I even went the extra step of chown'ing it to apache:apache for good measure. Still, when the script goes to open the file, it gives me the warning that the file doesn't exist and bombs out. No file is ever created.
Do I need to suppress the fopen() warning to get it to create the file?
file_exists()in case thea+was catching me up for whatever reason.