+ 1

Why the output is 0?

<?php $name="Aizaz Ahmed"; $title="teacher"; echo $name + " is a " + $title; ?>

28th Jul 2017, 11:00 AM
Vishal Agarwal
Vishal Agarwal - avatar
5 Respuestas
+ 8
Strings become 0 while conversion to integer in PHP. echo "one" + 2; => outputs 0 + 2 = 2
28th Jul 2017, 11:14 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 6
Concatenation varies from language to language.
29th Jul 2017, 6:24 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
so use . instead of +
28th Jul 2017, 11:34 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
means @Krishna Teja Yeluripati whenever we use '+' operator in strings it will give 0 whereas in python it will add two strings Thanks for your answer :)
28th Jul 2017, 12:23 PM
Vishal Agarwal
Vishal Agarwal - avatar
0
<?php $name = "Aizaz Ahmed"; $title = "teacher"; echo $name. " is a ". $title; ?>
30th Jul 2017, 5:43 AM
and yhz
and yhz - avatar