is_int and GET or POST

后端 未结 10 1299
傲寒
傲寒 2020-12-14 10:44

Why does is_int always return false in the following situation?

echo $_GET[\'id\']; //3
if(is_int($_GET[\'id\']))
    echo \'int\'; //not execut         


        
10条回答
  •  难免孤独
    2020-12-14 11:05

    Because $_GET is an array of strings.

    To check if the get parameter contains an integer you should use is_numeric()

提交回复
热议问题