What is the difference between these 2 PHP operators ?
The first one is
= and the second one is
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
They are both assignment operators.
= on it's own simply assigns a value to a variable, e.g.
$welcome = 'Hello'; echo $welcome;
Above would output 'Hello'.
.= will add the value onto the existing value of the variable, e.g.
$welcome = 'Hello'; $welcome .= ' Red Baron'; echo $welcome;
Above would output 'Hello Red Baron' (TIP: notice the space before the Red Baron in the second line above)
I hope that explains it a little better. If not check out the link below to the PHP documentation.