This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
在这两种情况下,它都返回 true:
结果:
It is returning true for me in both cases:
Result:
零,因为整数是空的。
因此,在检查 Is_numeric() 或 is_int() 之前,请确保没有检查是否为空
Zero, as an integer is empty.
So ensure that there is no check for empty before you check for Is_numeric() or is_int()
将传递 false,因为您将零作为字符串文字传递给它。您可以尝试将相同的内容传递为已经经过(我相信)parseInt(""); 的变量。
虽然我的 php 可能有点不对劲,但过去一两周我一直在不停地写 Javascript。
Will pass false because you are passing it the zero as a string literal. You could try passing the same thing as a variable which has gone through (I believe) parseInt("");
Though my php may be a little off, having been Javascripting nonstop the last week or two.
当您处理 REQUEST 时,最好首先使用 filter_input 检查输入。以下是从 $_GET 检查“id”的示例。
完整的示例
那么,该功能的版本 PHP >= 5.2。
When you are dealing with REQUEST is better check the input first by using filter_input. Here is an example check 'id' from $_GET.
the full example
Well, the feature come up with version PHP >= 5.2.
我在同样的问题上苦苦挣扎,碰巧数字后面有一个空格。
长话短说,无论数字是什么:
这是一个例子......
稍后在该过程中......
打印在屏幕上:
I struggeled on the same problem, and it happenned that there was a space after the number.
Long Story short, what ever the number is:
Here is an example...
Later in the process...
Printed on screen:
如果这个
0
实际上是布尔值FALSE
,也会发生这种情况。对于布尔值,
is_numeric()
始终返回FALSE
。This also can happen if this
0
is a booleanFALSE
in fact.is_numeric()
always returnsFALSE
for boolean.