jjb123 Posted May 17, 2007 Share Posted May 17, 2007 Hi everyone, first of I just want to say I am new here so please forgive my lack of advanced php skill. I am trying to run a tutorial website that requires a [code ] like function, I have tried everything I can thing of but nothing works, ether the quotes get messed up or the code does. I was just wondering if someone can point me in the direction of a tutorial to make a php and code display parser like the one on php freaks, that lets php and other code be displayed without being parsed. Thank you. Link to comment https://forums.phpfreaks.com/topic/51915-code-display-help/ Share on other sites More sharing options...
Barand Posted May 17, 2007 Share Posted May 17, 2007 Are you looking for something like http://www.php.net/highlight_string Link to comment https://forums.phpfreaks.com/topic/51915-code-display-help/#findComment-255972 Share on other sites More sharing options...
jjb123 Posted May 17, 2007 Author Share Posted May 17, 2007 Yes, I already know of that function. What I am asking for is a system that when I enter something like it will convert it to entities and highlight it if it is php. Kinda like bbcode. Link to comment https://forums.phpfreaks.com/topic/51915-code-display-help/#findComment-255973 Share on other sites More sharing options...
jjb123 Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, I got it. I used: function fetchCode( $code ){ //config $prefix = "<center><div class=\"codehead\">Code:</div><div class=\"code\">"; //HTML code to add before your code, to add a markup $suffix = "</div></center>"; //HTML code to close prefix $return = stripslashes($code); $return = highlight_string($return, true); $return = $prefix . $return . $suffix; return $return; } Link to comment https://forums.phpfreaks.com/topic/51915-code-display-help/#findComment-255978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.