How can I limit the max value of number?

后端 未结 9 1933
小蘑菇
小蘑菇 2021-01-19 11:09

I want to secure my page by checking if the value is digital (0,1,2,3) and if it is in the range from 0 to 120. I think ctype_digit function limits numbers, so

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 11:35

    if (!ctype_digit($_GET['category']) || $_GET['category'] > 120) die('')
    

    Basically this says "If it's not a number or if it's larger than 120, stop"

提交回复
热议问题