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

Thread: echo ...

  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Location
    Brighton, UK
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"]); 
    Last edited by Jak-S; 04-26-2006 at 06:35 PM.

  • #3
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    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 ' 3;

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

    // so will this
    $sum 3;
    echo 
    'two plus three equals ' $sum

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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 ' 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.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

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