Hi, I just want to know simple thing.. how do I add a string + 3....
like $num = 4; echo "$num + 3" and I want the output to be 7...do you get what I mean?
Sorry for my newbie questions 😛 Thanks..
Why not just do: echo $num + 3; ?
Diego
try $num = 4; $result=$num+3; echo $result;
...or just $num = 4; $num += 3; echo $num; // will output 7
That's all good...but is there a way to do it within an echo statement?
for instance:
$num = 5; echo "The number is ($num) and the number plus 3 is ($num+3)"; // where $num+3 equals 8
I hope you see what I mean..
Thanks..
Read Diego Huang's reply.
$num = 5; echo "The number is ($num) and the number plus 3 is (".$num+3.")";
Humm, still no luck..I tried the last one and it gave me Parse error: parse error, expecting ','' or';'' in c:\foxserv\www\num.php on line 3 <? $num = 5; echo "The number is ($num) and the number plus 3 is (".$num+3.")"; ?>
','' or
Any Idea?
Y'see, at this point I'd've looked at the manual again and saved everyone's time.
<? $num = 5; echo "The number is ($num) and the number plus 3 is (".($num+3).")"; ?>