show_source() function in PHP


The show_source() function outputs a file with the PHP syntax highlighted.

Syntax

show_source(file, return)

Parameters

  • file − The file name to display.

  • return − If this parameter is set to true, this function will return the highlighted code as a string, instead of printing it out. Default is false.

Return

The show_source() function returns the highlighted code as a string instead of printing it, if the return parameter is set to true otherwise, it returns true on success, or false on failure.

Example

The following is an example, wherein we are using a test file ("new.php") to output the file with the PHP syntax highlighted.

<html>
   <body>
      <?php
         show_source("new.php");
      ?>
   </body>
</html>

Output

The output of the browser.

<html>
   <body>
      <?php
         echo ("new.php");
      ?>
   </body>
</html>

Updated on: 30-Dec-2019

123 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements