gettype() and settype() : Variable Type « Language Basics « PHP






gettype() and settype()

<html>
<head>
     <title>Gettype() and Settype() Usage</title>
</head>
<body>
<?php
     $my_double = 100;
     $my_string = 1;
   
     print("\$my_double's data type is... (" . gettype($my_double) .") <br />");
     print("\$my_string's data type is... (" . gettype($my_string) .") <br />");
   
     settype($my_string, "string");
     settype($my_double, "double");
   
     print("\$my_double's data type is... (" . gettype($my_double) .") <br />");
     print("\$my_string's data type is... (" . gettype($my_string) .") <br />");
?>
</body>
</html>
           
       








Related examples in the same category

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