In this blog, I am going to explain Variable Type & Type Conversion in PHP.
variable type depends on the value of currently holds means when you declare a variable in PHP, You do not declare its type.
$value = “This is Variable”; // assign string
echo $value;
you can change variable’s type by assigning a new value of different type.
$val = 44; // integer string
echo $val;
Automatic type conversion-
A variable type can depend upon the text in which it is used. Some functions and operators can be expect the value of a particular type convert automatically that type of its value.
Output-
settype() – Change Variable’s Data Type-
The function settype($value, “Type”) can clearly set the type of variable to type where the type’s value may be array, string, boolean integer, object, null. then uses of settype($value “Type”).
Output–
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND