Solved

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

Posted on 2007-11-19
5
229 Views
Last Modified: 2010-04-21
Hi,

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="http://www.sitename.nl"><img src="http://www.sitename.nl/banners/mesjes468x60.gif" alt="MyAlt Text" border=0></a>
<!-- Einde 468x60 Banner -->
0
Comment
Question by:HPvH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 60 total points
ID: 20311424
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));

-r-
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20311551
better use <iframe>...</iframe> to display something like this info as table or grid section like... some cool examples at http://www.htmlcodetutorial.com/frames/_IFRAME.html
0
 

Author Comment

by:HPvH
ID: 20311704
I need a code that shows the code on a page so a person can cody the code and use it.

Like:

<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 />
&lt;/html&gt;</span>
</code></div>
0
 
LVL 5

Accepted Solution

by:
palanee83 earned 65 total points
ID: 20312275
yes you can like below


$codeToSHow=' <a border="0" href="http://www.sitename.nl"><img src="http://www.sitename.nl/banners/mesjes468x60.gif" alt="MyAlt Text" border=0></a>';

echo (htmlspecialchars($codeToSHow)


it will work
0
 

Author Closing Comment

by:HPvH
ID: 31409905
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question