4. PHP Loose type and Type Casting

PHP Loose type:

echo “<pre>”;
var_dump($v=”profile”);
var_dump($v=6);
var_dump($v=6.5);
var_dump(false == array());
var_dump(true == array());

Data type changing with casting:

$a=6.5;
echo (integer) $a;      //Run time type casting, only this line type cast
echo $a;
echo $a;

but if you permanently type cast. So you have to do use settype function

Data type changing with settype():

$a=9.6;
settype($a, “integer”);
echo $a;
echo $a;
echo $a;               //Result not change

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s