Jump to content

Displaying code in HTML


codebyren

Recommended Posts

Hi,

 

I am trying to print out html code so that a user can just copy and paste it from my site without having to dig into the page source.  I know this can be done with htmlentities but I am having a problem preserving any indentation etc. to keep it neat.  What do developers usually use for this?  For example:

 

<tr>
<!-- See how this is indented... -->
<td>data</td>
<td>more data</td> 
</tr>

 

I believe HTML Tidy will do this but the server in questions doesn't have it available so hoping there are alternative options that are also less of an overkill.

 

If it makes any difference, I will probably be generating the HTML with output buffering or pulling the source of a remote file using get_file_contents.

 

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/193424-displaying-code-in-html/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.