php如何判断输入的是数字 php如何判断输入的是数字,代码如何写啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if (is_numeric($_POST["product_id$i"])) { echo "<script>alert('error!');</script>"; exit; }不对啊 有错吗 是数字的话is_numeric返回true,你这样写就反了 $v="从php中得到的数据";if(is_numeric($v)){ if(!is_string($v)) { echo $v; }} 值判断is_numeric不行因为它是检测变量是否为数字或数字字符串 表单过来的值永远都是字符串,包括数组的元素也是字符串,所以才要用is_numeric $_POST["product_id$i"]))这里面怎么多了个$i,要加入到双引号的字符串,要这样:if (is_numeric($_POST["product_id".$i])) {echo " <script>alert('error!'); </script>";exit;} if (!isset($_POST["product_id".$i]) || !intval($_POST["product_id".$i])) { echo " <script>alert('error!'); </script>"; exit;} $v="XXXXXX";if(is_numeric($v)){ if(!is_string($v)) { echo $v; }} 如何实现无刷新的用户名检测! 提问 问个php隐藏传值的问题 为什么我这样子的替换会出错呢?我不知道哪里错了 上传图片以后为什么不能预览 正则表达式读取html代码的问题 请教这两个SQL语句是否一个效果? smarty 框架怎么 安装组建(急) 用postgres数据库构建网站的高手来帮个忙 帮我解释几个PHP代码程序?~ ssh2_connect() $_SERVER["REQUEST_URI"]在iis如何得到伪静态的地址?
echo "<script>alert('error!');</script>";
exit;
}不对啊 有错吗
$v="从php中得到的数据";
if(is_numeric($v))
{
if(!is_string($v))
{
echo $v;
}
}
值判断is_numeric不行因为它是检测变量是否为数字或数字字符串
$_POST["product_id$i"]))这里面怎么多了个$i,要加入到双引号的字符串,要这样:
if (is_numeric($_POST["product_id".$i])) {
echo " <script>alert('error!'); </script>";
exit;
}
if (!isset($_POST["product_id".$i]) || !intval($_POST["product_id".$i])) {
echo " <script>alert('error!'); </script>";
exit;
}
if(is_numeric($v))
{
if(!is_string($v))
{
echo $v;
}
}