$du=file_get_contents("./yy.txt");//读取yy txt字符串
preg_match("/password=(.*?)\n/is",$du,$p);
echo$p[1];//输出#password=后面的值
$rpp=str_replace($p[1],"替换后的值",$du);//替换#password=后面的值
file_put_contents("./yy.txt",$rpp);//重新写入文件,完成
打开文件的模式有错误,改为下列的方式
$filepath="num.txt";
$file = fopen($filepath,"r");
$idsum=fgets($file);
fclose($file);
$file2 = fopen($filepath,"w");
$idsum1=(integer)$idsum+1;
echo "idsum的值为".(integer)$idsum."; idsum1的值为".$idsum1;
fwrite($file2,$idsum1);
fclose($file2);
?>