Re: empty() in email message
| From: | Gary | Date: | Tue, 14 Dec 2010 03:51:29 +0000 |
| Subject: | Re: empty() in email message | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310014@lists.php.net to get a copy of this message | ||
"Paul M Foster" <paulf@quillandmouse.com> wrote in message
news:20101213181124.GQ21772@quillandmouse.com...
> On Mon, Dec 13, 2010 at 12:47:49PM -0500, Gary wrote:
>
>> I have an email message
>>
>> $msg = 'Name: $fname ' . ' $lname\n'
>> . "Phone: $phone\n"
>> . "Email: $email\n"
>>
>> and it works fine, however in this message there are about 30 variables
>> that
>> are being called...as such
>>
>> . "Order: beefschnitzel $beefschnitzel\n"
>> . "Order: beefstrips $beefstrips\n"
>> . "Order: cheesesausage $cheesesausage\n"
>> . "Order: crumbedsausage $crumbedsausage\n"
>> . "Order: chucksteak $chucksteak\n"
>> . "Order: cornedbeef $cornedbeef\n"
>> . "Order: dicedsteak $dicedsteak\n"
>> . "Order: filletmignon $filletmignon\n"
>>
>> I want to only send the message if the submitter enters an amount in the
>> form for the corresponding variable, instead of having a bunch of empty
>> messages. So I have been trying to use the empty() function as such:
>>
>> . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order:
>> beefolives
>> $beefolives\n'}
>>
>> But I am getting the error
>>
>> Parse error: syntax error, unexpected T_IF
>>
>> Can someone point me in the right direction?
>
> It looks like you're trying to do something like:
>
> $str = 'something' .
> if ($somethingelse)
> 'another string'
> else
> 'a different string';
>
> For one thing, you can't put a conditional on the right side of a
> concatenation mark (.). You'd have to do it this way:
>
> $str = 'something';
> if ($somethingelse) {
> $str .= 'another string';
> }
> else {
> $str .= 'a different string';
> }
>
> You also can't do:
>
> elseif (isset($beefolives)) {
> 'Order: beefolives $beefolives\n';
> }
>
> For one thing, surrounding the 'Order...' line with single quotes will
> cause the \n *not* to be interpreted as a newline. Second, your 'Order:
> beefolives...' does nothing. You haven't assigned it to anything or
> operated on that string in any way.
>
> You might want to study up on single versus double quotes, the
> concatenation operator (.), etc.
>
> Paul
>
> --
> Paul M. Foster
>
Paul
Thank you for your reponse. I will admit I get a little fuzzy on the single
v double quotation marks, generally the rule I go by is if it is a string, I
use singles, if any processing I use doubles. I am not recalling why did it
that way, perhaps I had doubles and it did not work so I was whittling down
the options....
Thank you again for your help.
Gary
__________ Information from ESET Smart Security, version of virus signature database 5700 (20101213)
__________
The message was checked by ESET Smart Security.
http://www.eset.com