Solved

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

Posted on 2007-11-19
5
223 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now