tags:

views:

81

answers:

4
echo "<p id='xlday'>'$_POST['day']'</p>";

Hi can anyone help me solve this problem, should be a simple one but i'm struggling for some reason! Thanks

+3  A: 
echo "<p id='xlday'>".$_POST['day']."</p>";
Ergo Summary
Hope this helps :)
Ergo Summary
ha, always forget those dots!!! thanks
benhowdle89
No problem- you can also use echo "<p id='xlday'>",$_POST['day'],"</p>"; its actually faster (by microseconds) in PHP to concatonate with commas as opposed to append.
Ergo Summary
This needs `htmlspecialchars()` to protect agains XSS attacks
Pekka
@Ergo Summary The `,` does not do any concatenation. It just separates the parameters given to the `echo` construct.
Alin Purcaru
@Alin, apologies, my bad english
Ergo Summary
Apologies, I wasn't aware you could "accept" answers!
benhowdle89
A: 

Do like this:

echo "<p id='xlday'>".$_POST['day']."</p>";
Repox
And to elaborate - you had to escape your double quoted sentence with double quotes - you were using single quotes...
Repox
+2  A: 
echo "<p id='xlday'>".$_POST['day']."</p>";

or

echo "<p id='xlday'>{$_POST['day']}</p>";

or

echo "<p id='xlday'>${_POST['day']}</p>";

or

echo "<p id='xlday'>$_POST[day]</p>";



I'll also add

echo "<p id='xlday'>", $_POST['day'], "</p>";

with the mention that it does not actually concatenate the strings, but rather outputs them one at a time.

Alin Purcaru
or `echo sprintf("<p id='xlday'>%s</p>", $_POST['day'])`. So many choices...
Marc B
A: 
jack
What does output buffering have to do with this question?
Rocket