Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-31-2008, 09:08 AM   PM User | #1
mpacaon
New Coder

 
Join Date: Jul 2008
Location: Manila, PH
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
mpacaon is an unknown quantity at this point
Assignment Operator .=

What does this assignment operator in PHP do?

PHP Code:
.=

// Example
x.=
mpacaon is offline   Reply With Quote
Old 07-31-2008, 09:24 AM   PM User | #2
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
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
rangana is offline   Reply With Quote
Old 07-31-2008, 09:29 AM   PM User | #3
mpacaon
New Coder

 
Join Date: Jul 2008
Location: Manila, PH
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
mpacaon is an unknown quantity at this point
Uhm.. What does the "dot" thing do? Does it multiply the 2 variables?
mpacaon is offline   Reply With Quote
Old 07-31-2008, 10:06 AM   PM User | #4
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,229
Thanks: 2
Thanked 190 Times in 188 Posts
djm0219 is on a distinguished road
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
djm0219 is offline   Reply With Quote
Old 07-31-2008, 10:19 AM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
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 )
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 07-31-2008, 10:37 AM   PM User | #6
ssonawa
New Coder

 
Join Date: Jul 2008
Location: India
Posts: 39
Thanks: 0
Thanked 2 Times in 2 Posts
ssonawa is an unknown quantity at this point
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
ssonawa is offline   Reply With Quote
Users who have thanked ssonawa for this post:
mpacaon (07-31-2008)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:13 PM.


Advertisement
Log in to turn off these ads.