Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I`m wonder why this not working

    echo gettype($_GET['id']); //returns string
  if(is_int($_GET['id']))
  {
   echo 'Integer';
  }

How to validate data passing from GET/POST if it is integer ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
216 views
Welcome To Ask or Share your Answers For Others

1 Answer

Can use

$validatedValue = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);

See http://php.net/filter_input and related functions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...