1// Check if variable is int
2$id = "1";
3
4if(!intval($id)){
5 throw new Exception("Not Int", 404);
6}
7else{
8 // this variable is int
9}
1<?php
2$strings = array('1820.20', '10002', 'wsl!12');
3foreach ($strings as $testcase) {
4 if (ctype_digit($testcase)) {
5 echo "The string $testcase consists of all digits.\n";
6 } else {
7 echo "The string $testcase does not consist of all digits.\n";
8 }
9}
10?>