[英]inaccurate data PHP when using POST method
我的PHP代码中有一个特殊的字符问题。 $ _POST方法正在检索$ customer_code。
当我输入一个具有特殊字符的值(例如'D&C')时,它可以发布确切的数据。
但在我的代码中。
If($customer_code != 'D&C') {//this will return true. i also tried using "
die($customer_code . ' - D&C'); //will return D&C - D&C
}
为什么POSTED'D&C'和静态'D&C'不相等? 我希望有一个人可以帮助我
如果您确定POST请求正在运行( 如注释中所指定,通过使用var_dump($_POST);
例如 ),则可能是编码问题。 如果您使用HTML表单访问PHP页面,请尝试将以下代码添加到表单中:
<form action="your_page.php" accept-charset="ISO-8859-1">
有关其用法的更多详细信息,请访问: http : //www.w3schools.com/tags/att_form_accept_charset.asp
更深入的文章: http : //kunststube.net/frontback/
谢谢你的帮助,但我已经解决了这个问题。
通过使用str_replace
$customer_code = str_replace("&","&",$customer_code);
特殊性格问题。 仍然感谢你的努力
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.