How to add a URL (link) in PHP code?

I have a “send.php” page. If the user submits all the required fields, then my page prints “thank you for your submission”.

However, I am trying to make it where after the “thank you” it will give them a link to click on, so it will allow them to go to another page.

I have tried different ways (using print and echo), but can’t seem to get it to work. Did I say I was inexperienced? I have searched quite a few sources, but can’t find out how to add a link to PHP code.

Any help is appreciated!

HTML 101:

<a href="page.html">Click here</a>

Echo that (be sure to escape the quotes!) and you’ll be golden.

Sorry, I should have been more specific. What if this is for an external link?

Would this be right?

echo " <a href="">Click here</a>";

I gotcha Kromey! Here is the code that I used (thanks to your help) and it works.

echo "   <a href=\\"\\">Click here to visit site</a>";

Thanks again!

or you can simply just use this code

echo '<a href="">Click here</a>';

but you’d only have to escape single quotes, and they’re pretty rare in URL’s
oh, and it’s better on the PHP parser because it doesn’t have to search for varibles in the string.

1 Like

I87 is exactly right, this is faster for the parser, but be aware that you cannot have variables in a string delineated by single quotes unless you use concatenation.

$hello = "world";
echo "Hello, $hello!"; //displays "Hello, world!"
echo 'Hello, $hello!'; //displays "Hello, $hello!"
echo 'Hello, '.$hello.'!'; //displays "Hello, world!"

… or output HTML the easy way. (supports $variables too)

echo <<<HTML
<a href="">Click here</a>


(Note that there cannot be any spaces or characters before HTML; )