Hello There,
I am trying to Develop a tutorial, and I like to display PHP Code on my page, so user can copy and paste it.
Can any one help me in simple term, how can I print PHP Code on my page, specially color coded (see example below). Any idea With Textarea Box as well as Without Textarea Box will be appreciated.
I like to display PHP Code as its displyed here: This is just an example
<?php
$path = "";
$max_size = 200000;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
?>
replace < and > with < and >
StarLion Said: replace < and > with < and >
Thanks StarLion, I did not understand your response, by changing < and > displays < and >.
Here I tried Textarea Tag which works; but displyed code are not color coded. Can anyone help, please.
<textarea cols="150" rows="10">
$path = "";
$max_size = 200000;
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']);
if (!$res)
{
echo "upload failed!<br>\
"; exit; } else { echo "upload sucessful<br>\
";
}
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\
";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\
";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\
";
</textarea>
Color coding is an entirely different kettle of fish… and about 6 levels of complexity higher.
sk89q
May 11, 2010, 10:27pm
5
Not too many standard libraries of languages have this… but you’re in luck!
http://php.net/highlight_string
force
May 11, 2010, 11:24pm
6
There’s the javascript syntax highlighter, which has any number of plugins based on it for various languages, CMSes, and libraries/frameworks.
Force Flow Said
http://alexgorbatchev.com/wiki/SyntaxHighlighter
There’s the javascript syntax highlighter, which has any number of plugins based on it for various languages, CMSes, and libraries/frameworks.
Thank you Force Flow, that is exactly what I need. Simple enough.
Once again, thank you very much.
system
May 13, 2010, 11:45am
9
Hello,
Apply the PHP function “htmlentities” to exchange everything positioned inside the CODEBOX bbcode.