+ 2
can we add one integer variable and one string variable????
4 Answers
+ 5
Yes you can add integer to string. php automatically casts the string to integer and adds it to the integer.
ex:"12"+10 will result in 22 as string 12 is cast into integer 12.
"11abc"+ 12 will result in 23 as 11 abc is cast to integer 11.
+ 2
For example
$str = "I'm " ;
$int = 20;
$Ăąge = $str + $int;
echo ($age);
=> The output is "I'm 20"
0
thanks for the ans... can you give me a real time example where we need addition of two different data
0
yes u can add in PHP because it is loosEly typed language.