Page 1 of 1

wrapping a variable in a html link tag

Posted: Sat Jun 07, 2003 1:47 am
by rabbiz
$link1 = "<a href="
$link2 = "> Click Here</a>"
$Website = $link1.$Website.$link2


getting a parse error, unexpected T-VARIABLE on line 2

it doesnt like the ">

I have been racking my brain trying to figure a way around this. anybody got any ideas or suggestions?

thanks
Chris

Posted: Sat Jun 07, 2003 2:58 am
by Trill
Why not do it just by..

$Website = "<a href=\"$Website\">Click here</a>";

seems easier to me.


Trill

Posted: Sat Jun 07, 2003 3:35 am
by rabbiz
lol ty,

I have no idea why I didnt think of that.

thx again

Posted: Sat Jun 07, 2003 4:05 am
by twigletmac
Much better to do it on one line, but thought I'd give you a heads up as to why that code wasn't working - you need a semicolon at the end of each line, so you should have:

Code: Select all

$link1 = "<a href="; 
$link2 = "> Click Here</a>"; 
$Website = $link1.$Website.$link2;
instead of:

Code: Select all

$link1 = "<a href=" 
$link2 = "> Click Here</a>" 
$Website = $link1.$Website.$link2
Mac

Posted: Sat Jun 07, 2003 5:42 am
by delorian
twigletmac wrote:Much better to do it on one line, but thought I'd give you a heads up as to why that code wasn't working - you need a semicolon at the end of each line, so you should have:

Code: Select all

$link1 = "<a href="; 
$link2 = "> Click Here</a>"; 
$Website = $link1.$Website.$link2;
And of course the double quotes are missing:

Code: Select all

$link1 = "<a href=""; 
$link2 = ""> Click Here</a>"; 
$Website = $link1.$Website.$link2;
And that was also a problem.

Posted: Sat Jun 07, 2003 8:12 am
by davro
Maybe something like this.

Code: Select all

printf ("<a href="%s" target="%s">%s</a>", $link, $target, $imageortext);

Posted: Sat Jun 07, 2003 9:15 am
by twigletmac
You really don't need printf() for that - printf() should be used when you need to format the output, not as a substitute for print() or echo().

Mac