use Validator; $variable = 50; if(!Validator::numeric($variable)) { echo "{$variable} is not a number"; } else { echo "{$variable} is a number"; } // Output: 50 is a number
use Validator; $string = "3.14"; if(!Validator::numeric($string)) { echo "{$string} is not a number"; } else { echo "{$string} is a number"; } // Output: 3.14 is a numberThe package library used to implement PHP Validator Number could be the Laravel Validation package, which provides a powerful validation system for PHP.