use php only
User can input ant value in text format Users have no restriction on the number of order items they can.
The program outputs the data type:
String
Integer
Boolean
Decimal
NULL
Requirements
1. You may not use an array
2. You may not use any 'is_' functions for checking null, bool, integer, decimal or string types.
3. You may not use regular expressions.
4. If the user enters 'null' the value should be null.
5. If the user enters 'true' or 'false' the value should be bool.
In this it takes input from user in $num variable.
<form action="" method="post">
Example value: <input name="example" type="text" />
<input name="submit" type="submit" />
</form>
<?php
if (isset($_POST['submit'])) {
$num = $_POST['example'];
if(strpos( $num, "." ) !== false){
echo "Decimal";
}
else if($num =="" or $num=="null"){
echo "NULL";
}
else if((int)$num != 0){
echo "Integer";
}
else if($num =="" or $num=="null"){
echo "NULL";
}
else if($num =="true" or $num=="false"){
echo "Boolean";
}
else if($num =="" or $num=="null"){
echo "NULL";
}
else {
echo "String";
}
}
?>
OUTPUT:
you can refer output
Get Answers For Free
Most questions answered within 1 hours.