Page 1 of 1
Whats best? setFrom(array($fm_email => $fm_name)) or with ""
Posted: Mon Apr 27, 2009 4:15 am
by geddi
Hello,
Chris said that both of these will work:
// set the sender
$message->setFrom(array($fm_email => $fm_name));
OR
// set the sender
$message->setFrom(array("$fm_email" => "$fm_name"));
But does it matter which is used ?
Just want to avoid problems later on

Re: Whats best? setFrom(array($fm_email => $fm_name)) or with ""
Posted: Mon Apr 27, 2009 5:30 am
by geddi
I got this reply from another forum.
Hope it helps someone
It won't make a difference in this case, the variables in double quotations will be parsed as PHP.
However, go without them in order to improve performance. Double quoted strings take slightly longer to execute since the interpreter has to determine if the string requires parsing or not.
Re: Whats best? setFrom(array($fm_email => $fm_name)) or with ""
Posted: Wed Apr 29, 2009 5:12 am
by echoDreamz
Also I heard that you can do "{$variable}" and PHP will automatically parse $variable.
This is just something I have been doing for years etc.
Re: Whats best? setFrom(array($fm_email => $fm_name)) or with ""
Posted: Thu May 07, 2009 1:27 pm
by coolfactor
echoDreamz wrote:Also I heard that you can do "{$variable}" and PHP will automatically parse $variable.
This is just something I have been doing for years etc.
Yes, I use the "{$variable}" format since it makes the string much easier to read.
Example:
Code: Select all
$str = "Your special coupon code is {$coupon_code}. Please enter this when completing your purchase.";
While also being easier to read, using parsed variables is also slightly more efficient than using concatenation.
Code: Select all
$str = 'Your special coupon code is '.$coupon_code.'. Please enter this when completing your purchase.';