I am trying to learn PHP and how to write to a file
i have Php up and running on a mac
when I try to write to a file
I get this error
/Library/WebServer/Documents/Php/read_write/config.txt
Warning: fopen(config.txt) [function.fopen]: failed to open stream: Permission denied in /Library/WebServer/Documents/Php/read_write/configure.php on line 77
ERROR: cannot open configuration file for writing
this is the code that generates the error
//check file
$configFile = 'config.txt';
echo 'test<br>';
echo file_exists($configFile). '<br/>';
echo is_readable($configFile). '<br/>';
echo is_writable($configFile). '<br/>';
//echo stat($configFile). '<br/>';
echo realpath($configFile). '<br/>';
//open and lock configuration file for writing
$fp = fopen($configFile, 'w+') or die ('ERROR: cannot open configuration file for writing');
//flock($fp, LOCK_EX) or die ('ERROR: Cannot lock configuration file for writing');
I have checked all the file permissions and they are set to read/write
if I change the file I am writing to to .txt instead of .ini
I get different results with the file_exists is_readalbe, is_writable tests
Is there perhaps a setting that must be set in the php.ini file?
thank you!
for any insite
Peter
psthree