![]() |
PHP Numbers
You must have noticed one thing that whenever we take the numbers in the identification, then its conversion becomes automatic Or we can say that whatever number we give through Varible, the data type of the number is automatically correct according to its data type.Then, if you assign a string to the same variable, the type will change to a string. PHP numbers with integersThis automatic conversion can sometimes break your code.
PHP Numerical Strings
The PHP is_numeric() function can be used to find whether a variable is numeric. The function returns true if the variable is a number or a numeric string, false otherwise.
Example
Check if the variable is numeric:
Example
</head>
<?php
// Check if the variable is numeric
$x = 5985;
var_dump(is_numeric($x));
echo "<br>";
$y = "5985";
var_dump(is_numeric($y));
echo "<br>";
$z = "59.85" + 100;
var_dump(is_numeric($z));
echo "<br>";
$xx = "Hello";
var_dump(is_numeric($xx));
NOTE :- Video on This Topic :- Soon
Have a Nice Stay Here : - )
<html>
</head>
<body>
<?php
$x = 5985;
var_dump(is_numeric($x));
echo "<br>";
$y = "5985";
var_dump(is_numeric($y));
echo "<br>";
$z = "59.85" + 100;
var_dump(is_numeric($z));
echo "<br>";
$xx = "Hello";
var_dump(is_numeric($xx));
?>
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
bool(false)
NOTE :- Video on This Topic :- Soon
Have a Nice Stay Here : - )
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.