FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How do you show HTML/PHP code on your website?





boringest
hi guys,

is there an easier way of displaying codes on your website without using
the ASCII codes?
warriordude
umm you can show them in images Confused
digibluez
Its the most easiest way,there is no other solutnio,i just did solved it,there is a thread for that kind.I have no idea what you think of easier.Textarea-flash-
Havent seen anyone parsing the code with GD lib images.would be funny.
Simulator
Well you could post it like this
Code:

<command>


then highlight it and go (on firefox) view selection source, and it gives you the code you need for all the < and >s you need
eluder
I suppose the best approach is to use graphics. It's kind of tricky, if you wish to highlight syntax/whatever, but the default fonts GD library has allow to calculate the image size correctly (fonts are monospaced).

I suppose a number of PHP snippets/ready to use tools can be found easily. I'd start from PHP site itself, there are many links there (don't forget to visit PEAR section). Also, although not a source of excellent code, Hot Scripts would do.

Finally, there are scripts galore on Source Forge.

If you are really stuck, I suppose I could lend a hand and make a sample PHP code. GD now is allowed to generate GIFs, and the output can be made very small.
althalus
Depending on what you want, you could check out php.net. I find the examples a bit confusing at times, as I'm not that good at php, but I've seen it in action. This will highlight your code, much like it's highlighted when you use th 'code' feuture on this forum*.

(* At least I think so, I've never used it here..)
mathiaus
Why graphics? Their nasty Twisted Evil
unless you dont want to use the codes at all and its not about having to change them youself? Smile

Heres a nice little code I use which works for me fine. I actually have the function in a seperate file and then include that!
Just change whats in $old (between the <<<HTML and the HTML;) works on php fine as well! Laughing

Code:
<?php

function converthtml($old) {
$search = array ('@<@', '@>@', '@\"@');                   
$replace = array ('&lt;', '&gt;', '&quot;');
echo preg_replace($search, $replace, $old);
}


$old = <<<HTML
<?php
<span style="font-color: #000fff;">hello people of the world.</span>
?>
HTML;

converthtml($old);
?>
izcool
Use show_source(); to show PHP's source codes with syntax highlighting.

Example :

Code:
<?php
show_source("test.php");
?>


If you have HTML in that page, that will be shown as well.

- Mike.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.