Programming Code Center(PCC)
[PHP]

(PCC)::[How-to-Check-if-a-variable-is-numeric-or-not-in-php]::[php]

File Name : index.php

<!DOCTYPE html>
<html>
<body>

<?php
// Check if the variable is numeric   
$x = 5985;
var_dump(is_numeric($x));

echo "<br>";

$x = "5985";
var_dump(is_numeric($x));

echo "<br>";

$x = "59.85" + 100;
var_dump(is_numeric($x));

echo "<br>";

$x = "Hello";
var_dump(is_numeric($x));
?>  

</body>
</html>

Output :

"; $x = "5985"; var_dump(is_numeric($x)); echo "
"; $x = "59.85" + 100; var_dump(is_numeric($x)); echo "
"; $x = "Hello"; var_dump(is_numeric($x)); ?>