Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

Solved: How Do I Print HTML Code Without It Executing?


(!)

TeddyVon's Avatar
TeddyVon TeddyVon is offline
Junior Member with 18 posts.
THREAD STARTER
 
Join Date: Jan 2009
Experience: Beginner
15-May-2010, 05:37 PM #1
Solved: How Do I Print HTML Code Without It Executing?
I am trying to streamline some work by having a PHP page automatically generate HTML code I can cut and paste into a webpage, save the page, and voila! Done!

I thought I needed to use the html special characters, but I'm running into problems.

echo '&lt' . 'img src="' . $dirname . $file . '"' . "<br>" . 'alt="AlternateText"' . "<br>" . 'title="TitleText"' . "<br>" . $dimensions[3] . "&gt" . "<br>";

prints:

&ltimg src="/images/updates/2009/Q4/12/02/CM/kitten.jpg"
alt="AlternateText"
title="TitleText"
width="590" height="885">

instead of (what I'm looking for):

<img src="/images/updates/2009/Q4/12/02/CM/kitten.jpg"
alt="AlternateText"
title="TitleText"
width="590" height="885">

It appears it is interpreting ('&lt' . 'img src="') as one long string instead of echoing the < and then "img=".

So, does anyone know how I either:
indicate the end of the HTML special character string &lt
or, achieve the same result a different way

Many thanks!
MarkHaigh's Avatar
MarkHaigh MarkHaigh is offline
Member with 32 posts.
 
Join Date: Mar 2010
Location: UK
15-May-2010, 05:46 PM #2
You need semi-colons on the ends - so '&lt;' - I forget this from time to time and it can wreak havoc :-)

Another way that might work for you is to output the code as the contents of a multiline text box:-
<textarea cols="50" rows="4" name="comment">$htmloutput</textarea>
TeddyVon's Avatar
TeddyVon TeddyVon is offline
Junior Member with 18 posts.
THREAD STARTER
 
Join Date: Jan 2009
Experience: Beginner
15-May-2010, 06:33 PM #3
AH! Thank you so much!
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
How to make HTML form with CAPTCHA? cmshelper Web Design & Development 2 17-Jul-2009 12:18 PM
Visual Basic Express 2005: How do you print a RichText box contents and save it. mattvot Software Development 1 27-Aug-2007 08:09 AM
printing html codes maverick999 All Other Software 0 25-Apr-2007 11:47 AM
Solved: How do I compress a .psd without shrinking it? TLS4 GatorBait All Other Software 8 28-Jul-2006 11:58 AM
How do you add HTML to Source Code pegge43 Software Development 11 29-Aug-2004 02:16 PM

WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2