How to display source code of the page with highlighted syntax in PHP

In this quick tutorial I am going to show you How to display source code of the page with highlighted syntax in PHP. If you have created any application and you want to share code on internet and allow to make code view-able on page then you can simply use One very cool function in php called show_source(), with the help this function you can easily display source code of the page with php highlighted syntax. See below example.

Suppose you have page named helloworld.php

And you want to display helloworld.php source code on html div then you can simply call show_source() function in php like this.
source.php

= show_source("helloworld.php") ?>

= show_source(“helloworld.php”) ?>

You only need to pass the page name in this function and it’ll return full page code with PHP highlighted syntax.

OutPut will be..

Leave a Reply

Your email address will not be published. Required fields are marked *

Top