PHP Validating Integer With Typecasting – String Function

<?php
if ($_POST['rating'] != strval(intval($_POST['rating']))) {
   print 'Your rating must be an integer.';
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.