我已經搜索了Stackoverflow,發現了一些類似的問題,但無法理解答案。我只在2天前學過PHP,所以請放心。
我的問題是,我正在使用一個窗體供用戶編寫並提交一些文本到文件中。當他們點擊提交時,文本被寫入文件,下次他們訪問表單時,文本將保留在表單中供他們修改。問題是,如果任何形式的報價被輸入並提交,那麼會在其前面添加一個\。
例子: 用戶寫道:「你好」 用戶點擊提交 形式重新加載和「你好」輸出爲\「你好\」
我知道\取消了的東西,如報價單,以便它可以以字符串的形式輸出,但是可以使用$ _POST來存儲表單數據,並且每當我使用引號時都不會有\。
請讓你的解釋詳細,因爲我只是PHP的新手。提前致謝。下面是代碼造成我的問題:
echo '<div class="wrap">';
// makes an if statement to check if the submit button has been pushed
if (isset($_POST['Submit1'])) {
// opens the include file and writes the contents of "left-form" to the file. left-form is the name of the html text area
$file = fopen($_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/mytheme/options/index_left.php', "w");
fwrite($file,$_POST["left_form"]);
fclose($file);
}
echo '<p><form method="POST" action=""><textarea rows="4" cols="50" name="left_form">';
// includes the contents of the file being written to as the text inside the text field
include $_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/mytheme/options/index_left.php';
echo '</textarea></p>';
echo '<input type="submit" value="Submit" name="Submit1"></form>';
// sets an if statement to check if the post button has been hit to display a message that it has been posted
if (isset($_POST['Submit1'])) {
echo htmlspecialchars($_POST["left_form"]) . '</br>HAS BEEN POSTED';
}
echo '</div>';
}
'var_dump(get_magic_quotes_gpc());'output? –
我在代碼的頂部寫了這個,它沒有區別,但是我在文本字段上面寫了int(0)。 – user2946010
然後它沒有啓用。 –