How to check whether a variable in $_GET Array is an integer?

前端 未结 9 1596
北恋
北恋 2020-12-10 20:46

I have a page like so:

http://sitename/gallery.php?page=2

It has pagination links at the bottom by which we can br

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 21:17

    if(!empty($_GET['page']) and is_numeric($_GET['page'])){
           $page = (int)$_GET['page'];
           echo "Page Number: ".$page;
    }
    

    is_numeric is probably what you need.

提交回复
热议问题