Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

PHP.Simple Code Highlight

Some PHP to perform some simple syntax highlighting. My main goals were to keep it "to the point" and server side. I did this fast so there may be aspects that need to be fixed, feel free to help me out.

How it works

Initiate the Simple Code Highlight class, point it at the url or file you want and let it do its job. It wraps bits of HTML around your syntax and returns an object that contains an array of parsed HTML (as lines of code), the raw data, and a few bits about caching (if you decided to use that aspect).

There are several parameters you can use to refine your use of the class, the most prominent being the use of a cache. The parameters you can use to refine your use of this aspect are annotated in code.

If you decide to include your own filters/regex patterns the things to look out for are ORDER, ORDER, ORDER. The reason, I provided a built in conditional that prevents nested labeling. So if you start small you may prevent a large match and vice-versa. With the provided filters I tried to keep things simple and generic as my own purposes were pretty minimal (JS, HTML, CSS).

Browser compatibility

Server side, so no real worries. However in the demo I did make use of some CSS that may no be fully compatible with older versions of IE.


My aspect is released under the MIT License.

I did include Normalize.css and the box model tweak from Paul Irish for general demo formatting purposes.

As well, I also included regular expression patterns I pieced together from all over. I'm not super keen on using them, but they have their purpose.


A quick way to highlight your syntax using PHP.







No releases published


No packages published