Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: echo ...

1. ## echo ...

why the next row:

PHP Code:
``` echo \$arrl["day"]." a ".\$arrl["day"] + \$arrl["periodo"]." de ".trata_month(\$arrl["month"]);  ```
gives

10 de Abril

and not

5 a 10 de Abril

• EDIT

Sorry, didnt read the code properly , try this, tho im not 100% sure what the problem is:
PHP Code:
``` echo \$arrl["day"]." a ".(\$arrl["day"] + \$arrl["periodo"])." de ".trata_month(\$arrl["month"]);  ```

• the syntax you are trying to use (an equation within an echo statement) will not work.
PHP Code:
``` // 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;  ```

• 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:
PHP Code:
``` 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:
PHP Code:
``` 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.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•