fopen documentationによれば、いくつかのモードではファイルが存在しない場合は作成されますが、私の状況ではすべて 'w'、 'w +'、 'x 'と' x + 'モードを使用していますが、私に警告を出すだけで、ファイルを作成することはできません。PHP fopen()はファイルを作成しません
それは私のコードです:
$this->handle = fopen($this->log_name, 'w');
と私は何を得る:
Warning: fopen(D:\xampp\htdocs\farid\logs\error.php) [function.fopen]: failed to open stream: No such file or directory in D:\xampp\htdocs\farid\libraries\error\log.php on line 34
Warning: fwrite() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\farid\libraries\error\log.php on line 66
Warning: fclose() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\farid\libraries\error\log.php on line 27
そして私は、Windows環境で働いています。
これらのディレクトリは存在しますか? – aynber
ファイルのパーミッションは最も明白な疑いです –
同じドキュメンテーションから - "PHPがfilenameがローカルファイルを指定していると判断した場合、そのファイルでストリームを開こうとします。安全なモードを有効にしている場合、またはopen_basedirにさらに制限が適用される可能性があります。 –