0

how can string variable and a integer can be added?

if $str="10"; and $int=20 then how the output becomes 30

19th Aug 2018, 5:32 PM
Bishal Shrestha
Bishal Shrestha - avatar
2 Answers
+ 2
Bishal Shrestha PHP will automatically change the type when you enter a number as a string. https://www.sololearn.com/learn/PHP/1796/
19th Aug 2018, 5:46 PM
Manual
Manual - avatar
+ 1
Use . instead of + for adding strings. $str . $int equals to "1020".
19th Aug 2018, 5:45 PM
Микола Федосєєв
Микола Федосєєв - avatar