Php 当内容有引号时 fwrite 不工作
Php fwrite not working when content has quotes
假设我有这种文本通过表单:
你好我叫迈克,朋友们叫我"SuperMike",你好'All'!
如您所见,文本包含两种类型的引号 (' "),当我尝试写入文件时,它出错了(空白文件)。
$text = $_POST['text'];
$myfile = fopen("text.html", "w");
fwrite($myfile, $text);
fclose($myfile);
根据我的理解,下面的代码会对你有所帮助
<form method="post">
<textarea name="valll"></textarea>
<input type="submit" name="ff">
</form>
<?php
if(isset($_POST['ff'])) {
$text = base64_encode($_POST['valll']);
/*echo $_POST['valll'];
exit;*/
$myfile = fopen("text.html", "w");
fwrite($myfile, base64_decode($text));
fclose($myfile);
}
?>
假设我有这种文本通过表单:
你好我叫迈克,朋友们叫我"SuperMike",你好'All'!
如您所见,文本包含两种类型的引号 (' "),当我尝试写入文件时,它出错了(空白文件)。
$text = $_POST['text'];
$myfile = fopen("text.html", "w");
fwrite($myfile, $text);
fclose($myfile);
根据我的理解,下面的代码会对你有所帮助
<form method="post">
<textarea name="valll"></textarea>
<input type="submit" name="ff">
</form>
<?php
if(isset($_POST['ff'])) {
$text = base64_encode($_POST['valll']);
/*echo $_POST['valll'];
exit;*/
$myfile = fopen("text.html", "w");
fwrite($myfile, base64_decode($text));
fclose($myfile);
}
?>