For example, say:
<?php
// Grab the ID from URL, e.g. example.com/?p=123
$post_id = $_GET['p'];
?>
How do I check if variable $post_id is a number, and a positive integer at that (i.e. 0-9, not a floating point number, fraction, or a negative number)?
EDIT: Can't use is_int 'cause $_GET returns a string. Think I need to use intval() or ctype_digit(), with the latter seeming more appropriate. For example:
if( ctype_digit( $post_id ) ) { ... }
$_GETreturns a string. Also please take a look at the edit in the question and let me know which solution you think is better.