What is " .= " for in PHP and when to use?



  • Good galera I am with a doubt was analyzing a code in php and saw that in a foreach is used the expression $main .= '...'; and I'd like to know what it's for and when use.



  • Concatenation of string

    Same as:

    $main = $main . '...';
    

    Ex:

    $main = 'teste';
    $main .= '1';
    $main .= '2';
    $main .= '3';
    

    echo $main; //irá imprimir 'teste123'


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2