php保存设置,php如何实现编辑和保存文件?
php如何實現編輯和保存文件?
本文實例講述了php實現編輯和保存文件的方法。分享給大家供大家參考。具體如下:
save_file.php:
session_start();
$handle = fopen($_POST['original_file_name'], "w");
$text = $_POST['file_contents'];
if(fwrite($handle, $text) == FALSE){
$_SESSION['error'] = 'There was an error';
}else{
$_SESSION['error'] = 'File edited successfully';
}
fclose($handle);
header("Location: ".$_POST['page']);
?>
read_file.php:
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Untitled Document$fileName = "location/of/orignal/file/my_file.php";
$handle = fopen($fileName, "r");
while (!feof($handle)){
$text = fgets($handle);
echo $text;
}
?>
希望本文所述對大家的php程序設計有所幫助。
本文地址:http://www.45fan.com/bcdm/16983.html
總結
以上是生活随笔為你收集整理的php保存设置,php如何实现编辑和保存文件?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 获取html中图片不显示,HTM
- 下一篇: 用什么写php最好用,php用什么开发工