115-a is_int — Find whether the type of a variable is integer1
1
1
bool(true)
850 is Integer.115-b is_int — is_float — Finds whether the type of a variable is float
1
1
bool(true)
5.63 is Float.115-c is_numeric — Finds whether a variable is a number or a numeric stringbool(true)
5.63 is Numeric.115-d is_string — Find whether the type of a variable is string
bool(true)
Wow is String.115-e is_bool — Finds out whether a variable is a boolean1
bool(true)
1 is Boolean.115-f is_null — Finds whether a variable is NULL1
bool(true)
is NULL.115-g is_array — Finds whether a variable is an array
bool(false)
50 is not an Array.115-h is_countable — Verify that the contents of a variable is a countable value1
bool(true)
115-i is_scalar — Finds whether a variable is a scalar1
bool(true)
115-j is_callable — Verify that the contents of a variable can be called as a function1
bool(true)
<?php
/*-------115-a is_int — Find whether the type of a variable is integer------- */
echo "</br><h7 class='myheading'>115-a is_int — Find whether the type of a variable is integer</h7></br>";
$var = 850;
//$var = 8.50;
//$var = "850";
//$var = NULL;
//$var = true;
echo is_int($var) ."<br>"; // if =1 , true , otherwise false
echo is_integer($var) ."<br>"; // same as is_int
echo is_long($var) ."<br>"; // same as is_int
var_dump(is_int($var))."<br>";
if(is_int($var)){
echo "<br> $var is Integer.";
}else{
echo "<br> $var is not an Integer.";
}
/*-------is_float — Finds whether the type of a variable is float------- */
echo "</br><h7 class='myheading'>115-b is_int — is_float — Finds whether the type of a variable is float</h7></br>";
$var1 = 5.63;
$var2 = 563;
//$var = '563';
echo is_float($var2) ."<br>";
echo is_float($var1) ."<br>";// same as is_float
echo is_double($var1) ."<br><br>";
var_dump(is_float($var1))."<br><br>";
if(is_float($var1)){
echo "<br> $var1 is Float.";
}else{
echo "<br> $var1 is not an Float.";
}
/*-------115-c is_numeric — Finds whether a variable is a number or a numeric string------- */
echo "</br><h7 class='myheading'>115-c is_numeric — Finds whether a variable is a number or a numeric string</h7></br>";
$var = 5.63;
//$var = 563;
//$var = '563';
//$var = NULL;
//$var = true;
//$var = 1;
//echo is_numeric($var) ."<br><br>";
var_dump(is_numeric($var))."<br><br>";
if(is_numeric($var)){
echo "<br> $var is Numeric.";
}else{
echo "<br> $var is not an Numeric.";
}
/*-------115-d is_string — Find whether the type of a variable is string------- */
echo "</br><h7 class='myheading'>115-d is_string — Find whether the type of a variable is string</h7></br>";
$var3 = "Wow";
//$var3 = "Yahoo Baba";
//$var3 = "555";
//$var3 = 555;
//$var3 = true;
echo is_numeric($var3) ."<br>";
var_dump(is_string($var3))."<br>";
if(is_string($var3)){
echo "<br> $var3 is String.";
}else{
echo "<br> $var3 is not an String.";
}
/*-------115-e is_bool — Finds out whether a variable is a boolean------- */
echo "</br><h7 class='myheading'>115-e is_bool — Finds out whether a variable is a boolean</h7></br>";
$var4 = true;
//$var4 = 'true';
//$var4 = 1;
echo is_bool($var4) ."<br>";
var_dump(is_bool($var4))."<br>";
if(is_bool($var4)){
echo "<br> $var4 is Boolean.";
}else{
echo "<br> $var4 is not an Boolean.";
}
/*-------115-f is_null — Finds whether a variable is NULL------- */
echo "</br><h7 class='myheading'>115-f is_null — Finds whether a variable is NULL</h7></br>";
$var5 = NULL;
//$var5 = 55;
//$var5 = "";
//$var5 = TRUE;
echo is_null($var5) ."<br>";
var_dump(is_null($var5))."<br>";
if(is_null($var5)){
echo "<br> $var5 is NULL.";
}else{
echo "<br> $var5 is not an NULL.";
}
/*-------115-g is_array — Finds whether a variable is an array------- */
echo "</br><h7 class='myheading'>115-g is_array — Finds whether a variable is an array</h7></br>";
//$var6 = array('A','B','C');
//$var6 = array(50,65,80.20);
$var6 = 50;
echo is_array($var6) ."<br>";
var_dump(is_array($var6))."<br>";
if(is_array($var6)){
echo "<br> $var6 is Array.";
}else{
echo "<br> $var6 is not an Array.";
}
/*-------115-h is_countable — Verify that the contents of a variable is a countable value------- */
echo "</br><h7 class='myheading'>115-h is_countable — Verify that the contents of a variable is a countable value</h7></br>";
$var7 = array(1,3,6);
//$var7 = array("A","B","C");
//$var7 = 56;
echo is_countable($var7) ."<br><br>";
var_dump(is_countable($var7))."<br><br>";
if(is_countable($var7)){
//echo "<br> $var7 is Countable.";
}else{
//echo "<br> $var7 is not an Countable.";
}
/*-------115-i is_scalar — Finds whether a variable is a scalar------- */
echo "</br><h7 class='myheading'>115-i is_scalar — Finds whether a variable is a scalar</h7></br>";
$var8 = 45;
//$var8 = 45.20;
//$var8 = TRUE;
//$var8 = array('A','B');
echo is_scalar($var8) ."<br>";
var_dump(is_scalar($var8))."<br>";
if(is_scalar($var8)){
//echo "<br> $var8 is Scalar.";
}else{
//echo "<br> $var8 is not an Scalar.";
}
/*-------115-j is_callable — Verify that the contents of a variable can be called as a function------- */
echo "</br><h7 class='myheading'>115-j is_callable — Verify that the contents of a variable can be called as a function</h7></br>";
function test(){
}
echo is_callable('test') . "<br>";
var_dump(is_callable('test'));
?>