?
Solved

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

Posted on 2007-11-19
5
Medium Priority
?
231 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 240 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 260 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

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

752 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