Warning: A non-numeric value encountered in C:\Users\USER\Desktop\learnphp\hello.php on line 61
52The variable is a boolean.
The variable is a string.
The variable is a string.
The variable is an integer.
The variable is a float.
<?php
$a_bool = true;
$a_str = "Hello, World!";
$a_str2 = 'PHP is great!';
$a_number = 42;
$a_float = 3.14;
if (is_int($a_number)) {
echo $a_number += 10 . "<br>"; // this line gives us the warning you see above. the solution is to echo the break:
// down like so:
// echo "<br>";
} else {
echo "The variable is not an integer.<br>";
}
if (get_debug_type($a_bool) == "bool") {
echo "The variable is a boolean.<br>";
} else {
echo "The variable is not a boolean.<br>";
}
if (get_debug_type($a_str) == "string") {
echo "The variable is a string.<br>";
} else {
echo "The variable is not a string.<br>";
}
if (get_debug_type($a_str2) == "string") {
echo "The variable is a string.<br>";
} else {
echo "The variable is not a string.<br>";
}
if (get_debug_type($a_number) == "int") {
echo "The variable is an integer.<br>";
} else {
echo "The variable is not an integer.<br>";
}
if (get_debug_type($a_float) == "float") {
echo "The variable is a float.<br>";
} else {
echo "The variable is not a float.<br>";
}
?>