highlight_file() function in PHP

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

Syntax

highlight_file(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 highlight_file() function returns the highlighted code as a string instead of printing it. Returns true on success, or false on failure, otherwise.

Example

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

   
      
   

Output

The output of the browser.

   
      
   
Updated on: 2019-12-30T06:39:35+05:30

267 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements