Jump to content

Hyperlink using PHP variable


Recommended Posts

One thing that I noticed:

<a href="$web"></a>

should be:

echo("<a href=\"$web\">$web</a>");

 

I don't know if you just left the echo out or what, but that line should work...

 

with $web being www.example.com: output is

<a href="www.example.com">www.example.com</a>

 

neylitalo

echo("<a href=\"$web\">$web</a>");

The parentheses aren't need and why use escape characters when they're not needed? I wouldn't suggest hiding variables inside of double quotes, at least not when you're using Dreamweaver because Dreamweaver won't highlight variables inside of quotes.

 

I just don't believe it's a good habit to get into.

 

echo '<a href="' . $web . '">' . $web . '</a>';

 

If you know that your contents are going to involve only one style of quotes it's much simpler just to prevent escape characters and march on with the contradicting style for opening and closing the statement.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.