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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.