Re: Re: Mixing $_POST with text in a variable
| From: | Tim Traver | Date: | Mon, 19 Jul 2004 18:43:12 +0000 |
| Subject: | Re: Re: Mixing $_POST with text in a variable | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191054@lists.php.net to get a copy of this message | ||
I think the better way is to use brackets to enclose your variable...
So it would look like this :
$message = "
Name: {$_POST['Name']}
Division: {$_POST['Division']}
Phone: {$_POST['Phone']}
Email: {$_POST['Email']}";
Tim.
At 11:15 AM 7/19/2004, Jason Barnett wrote:
Markus Stobbs 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 94When you have a variable that is inside a text string (double quotes) like that then you do not need to have the quotes for your array index. So in your case something like this should work: $message = " Name: $_POST[Name] Division: $_POST[Division] Phone: $_POST[Phone] Email: $_POST[Email]"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php