...

View Full Version : echo ...



pavmoxo
04-26-2006, 06:25 PM
why the next row:


echo $arrl["day"]." a ".$arrl["day"] + $arrl["periodo"]." de ".trata_month($arrl["month"]);

gives

10 de Abril

and not

5 a 10 de Abril

Jak-S
04-26-2006, 06:31 PM
EDIT

Sorry, didnt read the code properly :o , try this, tho im not 100% sure what the problem is:


echo $arrl["day"]." a ".($arrl["day"] + $arrl["periodo"])." de ".trata_month($arrl["month"]);

devinemke
04-26-2006, 06:35 PM
the syntax you are trying to use (an equation within an echo statement) will not work.


// this will not work
echo 'two plus three equals ' . 2 + 3;

// this will work
echo 'two plus three equals ' . (2 + 3);

// so will this
$sum = 2 + 3;
echo 'two plus three equals ' . $sum;

marek_mar
04-26-2006, 10:42 PM
The "." and the "+" operator have the same "weight". Just The same as + and - in math. Whichever comes first is used first.
5 - 2 + 4 is equal to 7 and not -1 becouse the addition is done first.
In the example:


echo 'two plus three equals ' . 2 + 3;

'two plus three equals ' . 2 will be evaluated first. When it comes to the addition it will look like this:


echo 'two plus three equals 2' + 3;

string('two plus three equals 2') will become int(0) and therfore you will get 0+3 which is equal to 3.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum