1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Web Design & Development' started by TeddyVon, May 15, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. TeddyVon

    TeddyVon Thread Starter

    Joined:
    Jan 13, 2009
    Messages:
    18
    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!
     
  2. MarkHaigh

    MarkHaigh

    Joined:
    Mar 21, 2010
    Messages:
    32
    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>
     
  3. TeddyVon

    TeddyVon Thread Starter

    Joined:
    Jan 13, 2009
    Messages:
    18
    AH! Thank you so much!
     
As Seen On
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/923271