好的,所以我对一个简单的文本区域有问题。我正在使用一种隐藏的页面,以便使用JSON轻松地对一些数据进行编码。但是,我的所有文本输入都会自动转义到某个地方,我不知道在哪里。我的所有$\u post变量都会自动运行
htmlentities()
脚本启动时的函数,如下所示:
$ani->i->post = $this->clean($_POST, true);
function clean($values, $unset = false) {
if (is_array($values)) {
foreach ($values as $key => $value) {
$newkey = strtolower($key);
$return[$newkey] = $this->clean($value);
unset($values[$key]);
}
return $return;
}
return htmlentities($values);
}
我不断地得到
\'
当我把值放回文本区域时,所有的单引号。
我找不到任何地方可以添加斜线,我不记得这是一个功能,当您从文本区域提交时,它们会自动添加,如果是这样,为什么它们在放回文本区域时不会返回到单引号?我真的需要运行变量吗
stripslashes()
让他们回到原来的状态?
编辑:
我的“test.php”文件如下:
<h1>To Be Encoded:</h1>
<form action="/test" method="post">
<textarea name="encode" rows="20" cols="50"><?= html_entity_decode($ani->i->post['encode']) ?></textarea>
<input type="submit" name="submit" value="Encode It!" />
</form>
<h1>Encoded By JSON:</h1>
<textarea name="encoded" rows="20" cols="50"><?= json_encode(html_entity_decode($ani->i->post['encode'])) ?></textarea>
<?php
die();
?>
P.S.
die()
只是为了与我的框架兼容。