我不太懂javascript。我有个类似的按钮。
<a href="" onClick="begen(<?php echo $post->ID; ?>); return false;">LIKE</a>和,
function begen(id)
{
$.ajax({
type:"POST",
url:"begen.php",
data:"id="+id,
cache:false
});
}begen()将post id作为POST头发送到begen.php。
我正在用is_integer()在begen.php上检查它的安全性
if(!is_integer($_POST["id"]))
die("It's not an integer");当我测试它时,开始(3)返回“它不是整数”。我不知道为什么它不是整数。
http://forum.jquery.com/topic/ajax-sending-json-data-with-boolean-value#14737000000976384:
HTTP is a text protocol with no concept of bools or ints, so everything needs to be stringified. The stringification of false is certainly not 0.如果一切都是字符串,我如何确定id实际上是一个id?
发布于 2012-01-10 20:48:30
所有GET和POST参数都作为字符串提供给脚本。你是在找is_numeric吗
下一次,在这里发布之前,先阅读文档。
is_integer的手册页上写着:此函数为:is_int().的别名。
is_int的手册页上写着:要测试变量是数字还是数字字符串(例如表单输入,它始终是字符串),必须使用is_numeric().。
https://stackoverflow.com/questions/8810302
复制相似问题