frost Posted August 20, 2007 Share Posted August 20, 2007 What is the code that makes the "PHP Example:"s on the tutorial pages here on PHP freaks? For example: http://www.phpfreaks.com/tutorials/146/0.php Did someone change the < > to < > manually or is it a script? Thanks much. Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/ Share on other sites More sharing options...
marcus Posted August 20, 2007 Share Posted August 20, 2007 htmlspecialchars(); Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329385 Share on other sites More sharing options...
Barand Posted August 21, 2007 Share Posted August 21, 2007 http://www.php.net/highlight_file http://www.php.net/highlight_string Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329387 Share on other sites More sharing options...
frost Posted August 21, 2007 Author Share Posted August 21, 2007 Ok so the thing is I want to html code around the tutorial: <table> <tr><td> <b>TITLE</b></td></tr> <tr><td> TUTORIAL STUFF </td></tr></table> and all of that is stored in my database, so if I do htmlspecialchars(); it will also display the table code... Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329388 Share on other sites More sharing options...
dbillings Posted August 21, 2007 Share Posted August 21, 2007 htmlspecialchars() will allow you to display html tags and characters on the page. Barrands even better method highlight will provide the lovely blue,red,green and orange colors for the various php and html elements in the text. If your mysql data is returned exactly as you typed it it will produce... TITLE TUTORIAL STUFF Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329420 Share on other sites More sharing options...
frost Posted August 21, 2007 Author Share Posted August 21, 2007 Well I tried: $string ="<table> <tr><td> TITLE</td></tr> <tr><td> TUTORIAL STUFF </td></tr></table>"; echo htmlspecialchars($string); Output: <table> <tr><td> TITLE</td></tr> <tr><td> TUTORIAL STUFF </td></tr></table> Am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329431 Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 Ok so the thing is I want to html code around the tutorial: <table> <tr><td> <b>TITLE</b></td></tr> <tr><td> TUTORIAL STUFF </td></tr></table> and all of that is stored in my database, so if I do htmlspecialchars(); it will also display the table code... Why are you storing all that in the database? Just store your tutorial part. Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329433 Share on other sites More sharing options...
frost Posted August 21, 2007 Author Share Posted August 21, 2007 The tutorial includse stuff that is code and stuff that is just me explaining things. How about this route: $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text); This is a BBcode thing but I wonder if I could be adapted? In this example it replaces everything between the bbcode "code" values. Is it possible to do something like this and instead of replacing everything just replace all instances of < and > with < > ? Quote Link to comment https://forums.phpfreaks.com/topic/65892-solved-php-freak-code/#findComment-329455 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.