[SOVLED] A PROBLEM WITH HEREDOC?!?!?!?!?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

ya I've found $_POST['something'] not to work, so i convert it to a variable first.

Code: Select all

$name = $_POST['name'];
echo <<<EOT
hey $name! You have no friends! bwahahaha.. im tired!
EOT;
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

You should have asked me instead ;). I'd turn you into a heredoc freak, free of charge :).

-Nay
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

LiLpunkSkateR wrote:ya I've found $_POST['something'] not to work, so i convert it to a variable first.

Code: Select all

$name = $_POST['name'];
echo <<<EOT
hey $name! You have no friends! bwahahaha.. im tired!
EOT;
As Nay said, put it into curly quotes:

Code: Select all

echo <<<EOT
hey {$_POST['name']}! You have no friends! bwahahaha.. im tired!
EOT;
Mac
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

I'm sorry but you guys actually compleatly missed my question, i guess i need to clear it up a bit,

what i'm doing is i made a loop for a menu, the url's and the link text ar captures from the post function, but on the previous page the url's and the link text are named LU_1, LU_2, LU_3, and LT_1, LT_2, LT_3, and what i'm doing but failing at doing is this

Code: Select all

$n1 = "0";
$the_num_num = "1";

while($_GET['number_of_links']>$n1)
{
Print <<< EOT
<a href={$_POST['LU_$the_num_num']}>{$_POST['LT_$the_num_num']}</a>
EOT;

$n1+;
$the_num_num++;
i need to have a variable inside of the $_POST function
i hope this clears up the problems in my earilier question!!!!
thanks a bunch!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Information in single quotes is not parsed:

Code: Select all

$foo = 'world';
echo "hello $foo";
outputs

Code: Select all

hello world
as does

Code: Select all

echo 'hello '.$foo;
but

Code: Select all

echo 'hello $foo';
outputs

Code: Select all

hello $foo
Try changing:

Code: Select all

$_POST['LU_$the_num_num']
to

Code: Select all

$_POST['LU_'.$the_num_num]
Mac
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

thanks a million, i had thought i had allready tried that but i just did and it works perfectly!
Post Reply