初学php,做了一个简单的在线编辑文件网页

编辑界面

<?php
function read()
{
	readfile("test.php");
}
?>
<form method="post" action="file.php">
<textarea id="edit" name="edit" rows="40" cols="100">
<?php
	read();
?>
</textarea>
<br/>
<input type="submit" value="上传" />  
<input type="reset" value="重置"  />
</form>

很简单,目前只是编辑某个特定文件


处理界面

<?php
$text=stripslashes($_POST['edit']);
file_put_contents("test.php",$text);
?>

这里发现一个问题,表单在用 POST 传送数据时,在接受数据时,发现如果传输数据有字符(‘  “  \),都会转义,字符前面会加’\',解决这个问题,可以设置php配置文件,

magic_quotes_gpc设置为on或者直接用 stripslashes()函数

stripslashes函数

更多推荐

php在线编辑文件网页