We help IT Professionals succeed at work.
Get Started

PHP $_POST in string

erzoolander
erzoolander asked
on
493 Views
Last Modified: 2012-05-12
Hey - quick and possibly boneheaded question.

If I'm building a string...say...

$body = "hello there variable one, variable two, variable three"...

and I want to substitute those variables from items in a $_POST array...

Is there a quick way for me to say...

$body = 'hello there $_POST['variable1'] $_POST['variable2']' etc etc...without having to break it up as...

$body = "Hello there";
$body .= $_POST['variable 1'];
$body .= etc etc?

When I attempt to do...

$body = 'hello there'.$_POST["variable1"].' '.$_POST["variable2"]'; etc...
it seems to glitch...keeping the actual PHP code in the string...and not the gathered array items.

?
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE