Question:
What is the different between “$headers” and “$headers .”?
fazlionline
2010-02-21 23:07:00 UTC
I am new PHP student.
Yesterday, I got this in a script .
The different between both is just in “.” at the end.
Can anyone tell me what the efferent between them is?
$headers = "From: myplace@here.com\r\n";
$headers .= "BCC: hidden@special.com\r\n";
Thanks
Three answers:
Memres
2010-02-21 23:18:04 UTC
The operator = assigns the strings.

The operator .= combines the original string with a new string.



so:

x.=y

is really just:

x=x.y



The operator . is used to combine strings.



"abc"."def" = "abcdef"



in your case:



$headers = "From: myplace@here.com\r\nBCC: hidden@special.com\r\n";
BeingGreenOnline
2010-02-21 23:16:23 UTC
The one with the period will append it to the existing value of $headers
thebig_a_27
2010-02-21 23:14:34 UTC
= is assignment, .= is concatenation



a = "one"



so a is "one"



a.= "two"



so now a is "onetwo"


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...