S4C Posted July 17, 2006 Share Posted July 17, 2006 Hmm how to be sure that my $_GET['page'] is really integer..?Thanks Quote Link to comment Share on other sites More sharing options...
Joe Haley Posted July 17, 2006 Share Posted July 17, 2006 http://ca3.php.net/manual/en/function.is-int.phpis_int is your friend.Edit:http://ca3.php.net/manual/en/function.is-numeric.phpis_numericuse is_numeric if the value you wish to test is of a string data type. Quote Link to comment Share on other sites More sharing options...
trq Posted July 17, 2006 Share Posted July 17, 2006 Anything sent through $_GET is technically a string, but you could try to force it into being an integer by using typecasting. eg;[code=php:0]if (isset($_GET['page'])) { $page = (int) $_GET['page'];}[/code]Or you might just check it using [url=http://php.net/is_numeric[/url](). Quote Link to comment Share on other sites More sharing options...
Prismatic Posted July 17, 2006 Share Posted July 17, 2006 The method above will turn a string of text sent via the $_GET into 0, FYI Quote Link to comment Share on other sites More sharing options...
S4C Posted July 17, 2006 Author Share Posted July 17, 2006 Thanks a lot guys. ;) Quote Link to comment Share on other sites More sharing options...
Orio Posted July 17, 2006 Share Posted July 17, 2006 is_int checks only if the variable is an integer.But if the number is being transfered using GET, POST etc', the variable will be a [b]string[/b] of number/s.So you need to use [url=http://www.php.net/manual/en/function.is-numeric.php]is_numeric()[/url].Orio. Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted July 17, 2006 Share Posted July 17, 2006 You can use [b]is_numeric[/b], convert to [b]intval[/b] and [b]is_int[/b] after each other to check. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.