Hi,
What does type casting mean in PHP? Explain with an example?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Mar 25, 2012, 9:16 AM
PHP automatically store the data and interprets according to itself. Type casting is a way to assign the variable according to your need and requirement and not allowing PHP to assign it automatically. To specify the type, it can be used like:
$newint = (int) $var1;
$newfloat = (float) $var1;
$newstring = (string) $var1;
The value in the variable on the right side of the equal sign is stored in the variable on the left side as the specified type.
Thanks
SenthilkumarPosted Mar 25, 2012, 8:44 AM
Please go through this url:
http://www.electrictoolbox.com/type-casting-php/
http://www.phpro.org/tutorials/PHP-Type-Casting.html