【发布时间】:2022-08-21 20:39:19
【问题描述】:
我有一个 PHP 代码,如下所示,在 POST 调用中,我得到的是加密值而不是字符。例如,输入Hello World\' 我得到这个Hello World'而不是控制台(from Line Z) 上的Hello World\'。
在form_validator.php 中,我使用以下内容:
if (isset($_POST[\"response\"]))
$response = $_POST[\"response\"];
print_r($response);
在form.php 中,我有以下代码:
<form id=\"acbdef\" name=\"abcdef\" action=\"#\" method=\"post\">
<table width=\"100%\" class=\"wb-tables table\">
<tr>
<td>
<?php echo SECRET_RESPONSE;?>:
</td>
<td colspan=\"2\"><input type=\"text\" id=\"response\" name=\"response\" value=\"\" /></td>
</tr>
</table>
</form>
<script>
// Test all the fields in another php page using javax and receive the result by JSON
$(\"#save\").click(function () {
$.post(\'form_validator.php\', $(\"#abcdef\").serialize(), function (data) {
console.log(data); // Line Z
});// end function(data)
});
</script>
在config.php 中,我有以下内容:
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
$_REQUEST = (array) $_POST + (array) $_GET + (array) $_REQUEST;
问题陈述 :
我想知道我需要在上面的 php 代码中进行哪些更改,以便使用 character itself 而不是 HTML coded apostrophe。
-
print_r 格式化结果,尝试使用 echo
-
您可以尝试将包含表单的页面的编码设置为e。 G。
<meta charset=\"utf-8\" />。恕我直言,这应该告诉 jquery post 函数正确编码。 -
你看过
html_entity_decode()和htmlspecialchars_decode()吗? -
我根本无法重现这一点。 jQuery doesn\'t transform the request data 和 PHP doesn\'t encode the response,无论您使用
print_r还是echo。您的特定设置必须涉及其他内容 -
@Phil 我已包含
config.php文件。让我知道这是否有帮助。
标签: php html jquery html-encode