If your server is configured to do so, you can serve highlighted .phps files; see the docs for details.
PHP4 has highlight_string() and highlight_file functions that are documented in the "Misc." section of the manual. The former would be your best bet for pulling snippets out of a database.