what is this .= ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
runrunforest
Forum Newbie
Posts: 6
Joined: Thu Sep 18, 2008 10:33 pm

what is this .= ?

Post by runrunforest »

this .= happened toappear between two strings. I don't know what it means.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: what is this .= ?

Post by onion2k »

It's the concatenation operator. Essentially it means "add the content of this string on to the previous string".
gsairam
Forum Newbie
Posts: 4
Joined: Fri Sep 05, 2008 5:38 am

Re: what is this .= ?

Post by gsairam »

Example:

<?php

$a = 3;
$a += 5; // sets $a to 8, as if we had said: $a = $a + 5;
$b = "Hello ";
$b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!";
echo $b;
?>


Hope its a continuation of the previous result of the variable. Here the output will be

Hello There!

The above expamle may help you better..
runrunforest
Forum Newbie
Posts: 6
Joined: Thu Sep 18, 2008 10:33 pm

Re: what is this .= ?

Post by runrunforest »

only apply for strings ?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: what is this .= ?

Post by onion2k »

runrunforest wrote:only apply for strings ?
Try it and see.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: what is this .= ?

Post by califdon »

Better yet, read the manual. Syntax questions are best answered by a fast search at the appropriate documentation web site.

PHP: http://www.php.net/docs.php

MySQL: http://dev.mysql.com/doc/

HTML, Javascript, CSS: http://w3schools.com/
Post Reply