Jump to content

What does .= does1


Recommended Posts

ok i been trying to get this which is weird because it just combine 2 things together, so what does .= really do and what does it really mean? i mean wouldnt it be easy to just use an = and call it a day? a brief detail would do, im still gonna be reading about it on google

Link to comment
Share on other sites

no, because they are not the same thing. if they were, it would almost be no point in having them. first you need to understand your operators. = is the assignment operator. is the contactenation operator I assume you know what each one does on it's own.

$x = 5;echo($x); //5 $x = 'hello';$y = 'world';$z = $x . ' ' . $y;echo($z);  //hello world

.= means to concatentate what is on the right of the assignment operator to what is on the left of the assignment operator

$x = 'hello';$x .= ' world';echo($x); //hello world

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...