When you declare a variable, there is no need to mention a specific type explicitly. PHP will take care of the automatic type conversion implicitly. That is to say, if you assign a string value to variable var, var becomes a string. If you then assign an integer value to var, it becomes an integer.
 
<?php
 

$var "0";                         // OUTPUT: ASCII 48 ($var is now string) 
$var += 2;                          // OUTPUT: 2 ($var is now an integer)  
$var $foo 1.3;                  // OUTPUT: 3.3 ($var is now a float)  
$var "10 Little Piggies";     // OUTPUT: 15 ($var is integer)  
$var "10 Small Pigs";         // OUTPUT: 15 ($var is integer)  

?>

0 comments:

Blog Archive

Total Pageviews

Popular Posts