Changing the Type of a Variable with settype() : Variable Type « Language Basics « PHP






Changing the Type of a Variable with settype()




<html>
<head>
<title>Changing the type of a variable with settype()</title>
</head>
<body>
<?php
$undecided = 3.14;
print gettype( $undecided ); 
print " -- $undecided<br>";  

settype( $undecided, string );
print gettype( $undecided ); 
print " -- $undecided<br>";  

settype( $undecided, integer );
print gettype( $undecided ); 
print " -- $undecided<br>";  

settype( $undecided, double );
print gettype( $undecided ); 
print " -- $undecided<br>";  

settype( $undecided, boolean );
print gettype( $undecided ); 
print " -- $undecided<br>";  
 ?>
</body>
</html>


           
       








Related examples in the same category

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