Testing the Type of a Variable : Variable Type « Language Basics « PHP






Testing the Type of a Variable


<html>
<head>
<title>Testing the type of a variable</title>
</head>
<body>
<?php
$testing = 5;
print gettype( $testing ); // integer
print "<br>";

$testing = "five";
print gettype( $testing ); // string
print("<br>");

$testing = 5.0;
print gettype( $testing ); // double
print("<br>");

$testing = true;
print gettype( $testing ); // boolean
print "<br>";
?>
</body>
</html>


           
       








Related examples in the same category

1.gettype() and settype()
2.Changing the Type of a Variable with settype()