TypeCasting in PHP

Changing data type of a certain variable from one type to another.

Source code :

<?php
$v1 = 12; // datatype ->integer 
$v2 = "cry"; // datatype ->string
$v3=(boolean)$v1; // $v1 is now a boolean
$v4=(float)$v2; // $v2 is now an float
print gettype($v1)."\n";
print gettype($v2)."\n";
print gettype($v3)."\n";
print gettype($v4);

Output :

integer
string
boolean
double

Output :


                

Comments :