Wednesday, August 7, 2013

Variable Casting

$myFloatInt = 1234.5678;
$myCastInt  = (int) $myFloatInt;
echo myCastInt;
//Will output "1234"
(array) (bool) (int64) (float) (double) (string) (object) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo gettype($myVar) . "<>br";
//This will show you what kind of variable you are using
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo is_string($myVar) . "<>br";
//T or F
is_bool - is_float - is_interger - is_null - is_object

No comments:

Post a Comment