Highlight Source Code using PHP

If you want to show the source code of a small piece of example code on your blog without paring them on the browser then come check the simple code using PHP…

Declare a string in php

Send that string as parameter for the builtin function highlight_string().

Code is…


<?php

    highlight_string('<?php
        $i = 1;

        function rockOut()
        {
            alert('Wah Wah Wah');
        }
    ?>');

?>

output:

highlight_string() function usage

highlight_string Function usage

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s