View Full Version : How to get code to be visible on a web page

08-05-2010, 12:21 PM

I want to show visitors to my site the code they need to use to make a link to my site.

Trouble is - when i use the code, it is converted into a link - i want the actual code for the link to be visible on the webpage so the visitor can copy it.

Any help appreciated.


08-05-2010, 03:04 PM
Are you talking about the URL to your website?

use php to get and display it:


echo $url;

or echo it into an input field:

<input type="text" value="<?php echo $url; ?>" />

08-05-2010, 03:37 PM
I've not used php before and i've tried the form code you mentioned but it doesn't seem to work.

The exact code i want to appear on the page is:

<p>We're a partner of <a href="http://www.findashopfitter.co.uk" target="_blank">Findashopfitter.co.uk for (insert your county or counties here).</a></p>

08-05-2010, 03:38 PM
Or, if you don't want to mess with php, then you need to convert the < and > symbols to their html equivalents - then the page will show the code not a link.

So, to display:<a href="mylink">Link text</a>

you need the following on your page:

&lt;a href="mylink"&gt;Link text&lt;/a&gt;

You'll see that < is replaced by &lt; and > by &gt; (less than and greater than symbols)

08-05-2010, 03:51 PM
The easiest way is to use a text area or input like stated above that is what most sites do.

08-05-2010, 03:52 PM
<textarea><a href="index.html">me</a></textarea>

08-05-2010, 03:56 PM
Sorry, i made a few mistakes in the last post. It works now:



echo "<form>";
echo "<input type='text' value='" . $url . "' />";
echo "</form>";


08-05-2010, 04:12 PM
cool - got it working. Thanks all.