<html>
<body bgcolor=lightyellow>
<H1 Align=center>Variable Type Functions</h1>
<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); //turn off notices and warnings
$var1;
$var2 = null;
$num1 = 123;
$num2 = 123.56;
$strNum = "123";
$str = "abc";
$now = time();
$array1 = array('a','b','c');
$array2 = array('a1'=>'xxx','b2'=>'yyy','c3'=>'zzz','d4'=>$array1);
$zero = 0;
$e;
echo '<table border=2>';
echo '<tr bgcolor=gray><th width=375>Declaration <th>Type/Value</tr>';
echo '<tr><td>$var0 <i>[not defined]</i> <td>', var_dump($var0);
echo '<tr><td>$var1; <td>', var_dump($var1);
echo '<tr><td>$var2 = null; <td>', var_dump($var2);
echo '<tr><td>$zero = 0; <td>', var_dump($zero);
echo '<tr><td>$num1 = 123; <td>', var_dump($num1);
echo '<tr><td>$num2 = 123.56; <td>', var_dump($num2);
echo '<tr><td>$strNum = "123"; <td>', var_dump($strNum);
echo '<tr><td>$str = "abc"; <td>', var_dump($str);
echo '<tr><td>$now = time( ); <td>', var_dump($now);
echo '<tr><td>$array1 = array("a","b","c"); <td>', var_dump($array1);
echo '<tr><td>$array2 = array(1=>"x",2=>"y","3"=>"z","4"=>$array1); <td>', var_dump($array2);
echo '</table>';
echo '<br><table border=2>';
echo '<tr><td>isset($var0) <td>', (isset($var0) ? 'true':'false'); //false
echo '<tr><td>isset($var1) <td>', (isset($var1) ? 'true':'false'); //false
echo '<tr><td>isset($var2) <td>', (isset($var2) ? 'true':'false'); //false
echo '<tr><td>isset($zero) <td>', (isset($zero) ? 'true':'false'); //true
echo '<tr><td>isset($num1) <td>', (isset($num1) ? 'true':'false'); //true
echo '<tr><td>isset($num2) <td>', (isset($num2) ? 'true':'false'); //true
echo '<tr><td>isset($array1[0]) <td>', (isset($array1[0]) ? 'true':'false'); //true
echo '<tr><td>isset($array1[3]) <td>', (isset($array1[3]) ? 'true':'false'); //false
echo '<tr><td>is_numeric($num1) <td>', (is_numeric($num1) ? 'true':'false'); //true
echo '<tr><td>is_numeric($strNum) <td>', (is_numeric($strNum) ? 'true':'false'); //true
echo '<tr><td>is_integer($num1) <td>', (is_integer($num1) ? 'true':'false'); //true
echo '<tr><td>is_integer($num2) <td>', (is_integer($num2) ? 'true':'false'); //false
echo '<tr><td>is_string($str) <td>', (is_string($str) ? 'true':'false'); //true
echo '<tr><td>is_string($strNum) <td>', (is_string($strNum) ? 'true':'false'); //true
echo '<tr><td>empty($var0) <td>', (empty($var0)? 'true':'false'); //true
echo '<tr><td>empty($zero) <td>', (empty($zero) ? 'true':'false'); //true
echo '<tr><td>empty($num1) <td>', (empty($num1) ? 'true':'false'); //false
echo '<tr><td>is_scalar($num1) <td>', (is_scalar($num1) ? 'true':'false'); //true
echo '<tr><td>is_scalar($array1) <td>', (is_scalar($array1) ? 'true':'false'); //false
echo '<tr><td>is_scalar($array1[0]) <td>', (is_scalar($array1[0]) ? 'true':'false'); //true
echo '<tr><td>is_array($array2) <td>', (is_array($array2) ? 'true':'false'); //true
echo '<tr><td>gettype($var0) <td>', gettype($var0); //NULL
echo '<tr><td>gettype($var1) <td>', gettype($var1); //NULL
echo '<tr><td>gettype($var2) <td>', gettype($var2); //NULL
echo '<tr><td>gettype($num1) <td>', gettype($num1); //integer
echo '<tr><td>gettype($num2) <td>', gettype($num2); //double
echo '<tr><td>gettype($str) <td>', gettype($str); //string
echo '<tr><td>gettype($now) <td>', gettype($now); //integer
echo '<tr><td>gettype($array2) <td>', gettype($array2); //array
echo '<tr><td>gettype($array2[0][1])<td>', gettype($array1[0][1]); //string
echo '</table>';
echo '<br><b> print_r($num1): </b><br>';
print_r($num1);
echo '<br><b> print_r($array1): </b><br>';
print_r($array1);
echo '<br><b> print_r($array2): </b><br>';
print_r($array2);
echo '<br><br><b> var_dump($num1): </b><br>';
var_dump($num1);
echo '<br><b> var_dump($array1): </b><br>';
var_dump($array1);
echo '<br><b> var_dump($array2): </b><br>';
var_dump($array2);
echo '<br><br><b> var_export($num1): </b><br>';
var_export($num1);
echo '<br><b> var_export($array1): </b><br>';
var_export($array1);
echo '<br><b> var_export($array2): </b><br>';
var_export($array2);
echo '<br><br>';
?>
<?php include "../include.php"; ?> <!-- hyperlink to see the code -->
</body>
</html>