-2

What is the difference between these 2 PHP operators ?

The first one is = and the second one is .=.

closed as off-topic by gnat, MetaFight, user40980, user22815, Ixrec Mar 9 '16 at 13:41

  • This question does not appear to be about software engineering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Whoever marked this for closing as "unclear what you're asking" - really? It seems very clear to me. Why is "unclear" turning into a catch-all close reason? – Jules Mar 3 '16 at 9:52
  • 4
    this seems more like a google question. This answer can even be found on w3schools.com with almost no effort. – Joe Mar 3 '16 at 10:11
  • 5
    I'm voting to close this question as off-topic because it is about a language's operators and can be easily googled. – MetaFight Mar 3 '16 at 10:23
  • 2
    I googled "List of PHP operators" (google.co.uk/…) and, at least for me, the first result is w3schools.com/php/php_operators.asp – MetaFight Mar 3 '16 at 10:46
  • 2
    I guess the trick here is to know that google often removes punctuation and symbols from searches so == and .= in your search might not have been considered. Oh, and you should probably also mention the language you searching about. – MetaFight Mar 3 '16 at 10:49
1

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.

http://php.net/manual/en/language.operators.assignment.php

  • Thanks alot Zenith, it's very simple things like those that make it easier to understand programming. Yet there's an army of thumbdowners who contribute to the depression and sadness when it comes to programming. – Red Baron Mar 3 '16 at 9:40
  • 5
    @RedBaron you misunderstand why we downvote. The reason content like this gets downvoted is to protect our other existing content. This question's value is relatively low because the answer is easily found on google. A lot of effort is put into keeping only high value questions on this site... which is why yours was downvoted. – MetaFight Mar 3 '16 at 10:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.