当内容引用

时间:2016-11-09 11:04:41

标签: php quotes fwrite

假设我有这种文字通过表格:

您好我的名字是Mike,朋友给我打电话" SuperMike",你好' All'!

正如您所看到的,文本包含两种类型的引号('"),当我尝试编写文件时,它只会出错(空白文件)。

$text = $_POST['text'];
    $myfile = fopen("text.html", "w");
    fwrite($myfile, $text);
    fclose($myfile); 

1 个答案:

答案 0 :(得分:3)

根据我的理解,下面的代码可以帮助您

<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);
}

?>