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
<html> <body> <?php echo ("Hello World"); ?> </body> </html>
And you want to display helloworld.php source code on html div then you can simply call show_source() function in php like this.
<div class="sourcecode"> <?= show_source("helloworld.php") ?> </div>
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..
<div class="sourcecode"> <html> <body> <?php echo ("Hello World"); ?> </body> </html> </div>