JustMatthew JustMatthew - 1 year ago 117
PHP Question

PHP does not echo text before + and - sign

With the following code:

echo $a."%".$b." maradéka: "." = ".$a % $b."<br>";
echo $a."+".$b." összege: "." = ".$a + $b."<br>";

I get this output:

1%1 maradéka: = 0

As you can see, the + syntax is the same as the % but it doesn't echo the text before the operation. Maybe I'm too tired or i don't know, but i can't figure it out :D
I've built dynamic web pages so far, but this one got me.

Answer Source

It is taking the numeric value of the first part and adding it to the second part. You'll want to group your math using parenthesis.

echo $a."%".$b." maradéka: "." = ".$a % $b."<br>";
echo $a."+".$b." összege: "." = ".($a + $b)."<br>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download