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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    Manila, PH
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Assignment Operator .=

    What does this assignment operator in PHP do?

    PHP Code:
    .=

    // Example
    x.=

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    It's concatenation.

    It does mean the same thing as:
    PHP Code:
    x=x.
    Hope that makes sense.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New Coder
    Join Date
    Jul 2008
    Location
    Manila, PH
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Uhm.. What does the "dot" thing do? Does it multiply the 2 variables?

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,312
    Thanks
    4
    Thanked 206 Times in 203 Posts
    The dot is the string concatenation operator. See this page of the PHP documentation for the complete details. The .= is referred to as the "concatenating assignment operator".
    Dave .... HostMonster for all of your hosting needs

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Well, it's the shorthand assignment operator.

    a.=b is equivalent to a=a.b, similarly]
    a+=b is equivalent to a=a+b

    (See http://www.exforsys.com/tutorials/c-...operators.html =>4. Assignment Operators )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New Coder
    Join Date
    Jul 2008
    Location
    India
    Posts
    39
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Smile Concatenation- joining two strings

    In PHP, period is used for concatenating, joining two strings together.

    Consider following example,

    $a = "Hello ";
    $b = $a . "World!"; // now $b contains "Hello World!"

    $a = "Hello ";
    $a .= "World!"; // now $a contains "Hello World!"

    Hope your doubt has got cleared, refer php.net, great resource for PHP F1

  • Users who have thanked ssonawa for this post:

    mpacaon (07-31-2008)


  •  

    Posting Permissions

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