Show code on your site, so they can copy it.


I want to show this code in a frame or table so people can copy it and use it on there own site.

How to show code on a php page??

<!-- Start 468x60 Banner -->
      <a border="0" href=""><img src="" alt="MyAlt Text" border=0></a>
<!-- Einde 468x60 Banner -->
Who is Participating?
palanee83Connect With a Mentor Commented:
yes you can like below

$codeToSHow=' <a border="0" href=""><img src="" alt="MyAlt Text" border=0></a>';

echo (htmlspecialchars($codeToSHow)

it will work
RoonaanConnect With a Mentor Commented:
You can use htmlspecialchars() to escape your tags:

echo htmlspecialchars($code);

To replace newlines with <br /> tags as well you can use:

echo nl2br(htmlspecialchars($code));

Loganathan NatarajanLAMP DeveloperCommented:
better use <iframe>...</iframe> to display something like this info as table or grid section like... some cool examples at
HPvHAuthor Commented:
I need a code that shows the code on a page so a person can cody the code and use it.


<div class="phpcode"><code><span class="html">
&lt;html&gt;<br />
 &lt;head&gt;<br />
   &lt;title&gt;Voorbeeld&lt;/title&gt;<br />
 &lt;/head&gt;<br />
 &lt;body&gt;<br />
<br />
   <span class="default">&lt;?php <br />
   </span><span class="keyword">echo </span><span class="string">"Hallo! Ik ben een PHP script!"</span><span class="keyword">; <br />
   </span><span class="default">?&gt;<br />
</span><br />
 &lt;/body&gt;<br />
HPvHAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.