I recently was told there is FILTER_VALIDATE_INT which is great by the way.
My question is in terms of taking an integer value from the website whether it maybe from user or generated from the web application, and passed via query string.
The value (integer) may be displayed or used in mysql query.
I am trying to structure the best possible security method for this.
With that in mind, is it safe to simply use
$myNum = (int)$_GET['num'];
Or
if (filter_var($_GET['num'], FILTER_VALIDATE_INT)) $myNum = $_GET['num'];
Also, please explain what is the difference between using (int) and FILTER_VALIDATE_INT
FILTER_SANITIZE_NUMBER_INTis equivalent to(int)casting.