+ 2

I understand..What is just happening in this code.....but will anyone would explain me is it good or bad....?

.see the code <?php $name = '2_Jo_1_hn'; $age = 25; echo $name+$age; ?>

11th Nov 2017, 10:07 AM
barot kuldip
barot kuldip - avatar
6 Antworten
+ 10
This is why I don't like Php :( It's adding the number portion of name (2) and age. 2+25 = 27 If you remove "2" from name variable, it'll print 25
11th Nov 2017, 10:19 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 7
compiler skips the line from _ symbol. this is a tricky exam question. use <?php $name = '2_Jo_1_hn'; $age = 25; echo $name.$age; ?>
11th Nov 2017, 10:18 AM
Asiri H
Asiri H - avatar
+ 5
Well I don't get what you mean if this code is good or bad.. but echo is "bad" to be used to display variables.. because you can display them on html code and customise them with css using for example <p> <?=$name + $age ?> </p>
11th Nov 2017, 10:26 AM
Basilhs Mixahl
Basilhs Mixahl - avatar
+ 4
use dot operator for concatenation
11th Nov 2017, 10:22 AM
Asiri H
Asiri H - avatar
+ 2
ok.... thank you for the explanation....brother...
11th Nov 2017, 10:19 AM
barot kuldip
barot kuldip - avatar
+ 1
yes....i saw that.....too....so many typical things are surrounded with php programming....m😁😁
11th Nov 2017, 10:20 AM
barot kuldip
barot kuldip - avatar