Re: Mixing $_POST with text in a variable
| From: | Cosmin Chiru | Date: | Mon, 19 Jul 2004 18:46:02 +0000 |
| Subject: | Re: Mixing $_POST with text in a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191055@lists.php.net to get a copy of this message | ||
Hello Markus,
Monday, July 19, 2004, 8:17:24 PM, you wrote:
> I'm changing my HTTP POST variable declarations from $variablename to
> $_POST['variablename'] to make my code more compliant with current best
> practices.
> However, I find that I cannot mix these new variable declarations into
> big variable strings like I used to. For example, this works:
> $message = "
> Name: $Name
> Division: $Division
> Phone: $Phone
> Email: $Email";
> ...but when I change $Name and the other variables to $_POST['Name'], I
> get this error:
> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in
> /web/scd/vets/Vislab/eventrequest.php on line 94
> Is there any clean way to avoid having to completely reconstruct all my
> form mail messages by constantly closing quotes, using . to connect text
> and variables within the larger variable.
> Markus
$message = "Name: $_POST['Name']\n";
$message .= "Division: $_POST['Division']\n";
$message .= "Phone: $_POST['Phone']\n";
$message .= "Email: $_POST['Email']\n";
--
Best regards,
Cosmin mailto:Psyche@wolfheart.ro