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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post

    Need help understanding the dot "."

    I'm trying to learn how the period "." works. Sometimes its concatenation, sometimes its echoed to the browser.

    I'm trying to add a string, such as:
    PHP Code:
    '_string' 
    ...to a set of variables, such as:
    PHP Code:
    $M3 'May';
    $hi '1';
    $Y '2012'
    To get this:
    PHP Code:
    "May12012_string" ( or with single quotes 
    I asked this question before, and got an answer, but I can't get it to work anymore. For example, this:
    PHP Code:
    $time ".$M3.$hi.$Y.";
    echo 
    $time
    Shows up as this in the browser:
    PHP Code:
    .Jul.11.2012
    This:
    PHP Code:
    $time '".$M3.$hi.$Y."8AM';
    echo 
    $time
    Sends this to the browser:
    PHP Code:
    ".$M3.$hi.$Y."8AM 
    This brings the variables together like I want:
    PHP Code:
    $time "$M3$hi$Y";
    echo 
    $time
    Sends this to the browser:
    PHP Code:
    May12012 
    But adding a string to it like this:
    PHP Code:
    $time '"$M3$hi$Y"8AM'
    echo $time
    Sends this to the browser:
    PHP Code:
    "$M3$hi$Y"8AM 
    What is the difference between this (when is this necessary?):
    PHP Code:
    ".$M3." 
    and this:
    PHP Code:
    "$M3" 
    I hope I asked the question clearly.
    Thanks for your help.

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,996
    Thanks
    15
    Thanked 233 Times in 233 Posts
    PHP Code:
    this 
    $time 
    ".$M3.$hi.$Y."should give you .May.2.2012.
    but this 
    $time 
    $M3.$hi.$Yshould give you May22012
    and this
    $time 
    $M3.".".$hi.".".$Yshould give this May.2.2012 
    Confusing enough? It is for me! It gets better with practice.

  • #3
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    Practice is definitely what I'm doing.

    I've figured out this:
    PHP Code:
    $M3.$hi.$Y.'8AM_list' 
    ...will give me this:
    PHP Code:
    Jul120128AM_list 
    This:
    PHP Code:
    '"'.$M3.$hi.$Y.'8AM_list"' 
    Will send this to the browser:
    PHP Code:
    "Jul120128AM_list" 
    Last edited by milesdriven; 07-28-2012 at 12:49 AM.

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,996
    Thanks
    15
    Thanked 233 Times in 233 Posts
    '"'.$M3.$hi.$Y.'8AM_list"'

  • #5
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hi DrDos,

    Thanks. I posted the very same thing (I just figured it out with the help of your earlier example) about the same time you answered. I wanted to be able to do it with quotes and without.

    Thanks!
    Last edited by milesdriven; 07-28-2012 at 12:56 AM.


  •  

    Posting Permissions

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