What is the best way to show code on php page, like code snippets here(ew). I load the source to DB and read it from there and i want to show the source code so, that code won't be parsed, not even html. Oh, and also; How to keep line breaks in right place so, that the code block wouldn't look like a table with a thousand characters in it?
Thanks.
BTW. The code doesn't have to be highlighted.
Showing source
Moderator: General Moderators
-
Phodetheus
- Forum Newbie
- Posts: 1
- Joined: Wed Jul 02, 2003 3:23 am
- Location: Kent, UK
- Contact:
Ripped from PHPBB:
Code: Select all
<?php
preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $variable);
?>-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
http://www.w3schools.com/xhtml/xhtml_reference.asp
http://www.w3schools.com/html/html_reference.asp
those links have the html/xhtml tags. i know there's multiple tags that will work. pic one that works with both, because html is being deprecated for xhtml
and you need to replace the < with < and > with >
http://www.w3schools.com/html/html_reference.asp
those links have the html/xhtml tags. i know there's multiple tags that will work. pic one that works with both, because html is being deprecated for xhtml
and you need to replace the < with < and > with >
Also the PHP-functions highlight_file() and highlight_string() are useful. They basically display PHP-code exactly the same way as phpBB (e.g. this board).