[英]can't write into file php no error
I am trying to write data into a text file from php using fwrite
or file_put_contents
. 我正在尝试使用
fwrite
或file_put_contents
从php将数据写入文本文件。 Although both fwrite
and file_put_contents
return 20 indicating Write operation successful and that 20 bytes were written into the file, but i can't find anything in the file. 尽管
fwrite
和file_put_contents
返回20表示写操作成功,并且20字节已写入文件,但是我在文件中找不到任何内容。 What might be the issue?? 可能是什么问题?
SO what is the problem here?? 那么这是什么问题呢?
<?php
$file_name = "user_notes.txt";
$file_write_handle = fopen($file_name,'w');
$data = " i am a disco dancer";
if(file_exists($file_name))
{
echo "exist";
}else{
echo "absent";
}
echo " ";
if(is_writable($file_name))
{
echo "writable";
}else {
echo "cant write";
}
$fw=fwrite($file_write_handle, $data);
echo "fw result" . $fw . "<br/>";
$fpc=file_put_contents($file_name, $data);
echo "fpc result : " . $fpc;
fclose($file_write_handle);
?>
当我在本地服务器上工作并且文件正在写入并存储在服务器而不是本地计算机上时,问题已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.