追加模式正在工作,但当我尝试在linux服务器上使用php编写文本文件时写入模式不起作用

Code in append mode

$target_dir ="status.txt";
$handle = fopen($target_dir, 'a') or die('Cannot open file:  '.$target_dir);
$data = '0';
fwrite($handle, $data);

Code in write mode

$target_dir ="status.txt";
$handle = fopen($target_dir, 'w') or die('Cannot open file:  '.$target_dir);
$data = '0';
fwrite($handle, $data);

I gave full permission of status.txt file but write mode is not working