PHP | highlight_file() Function Last Updated : 29 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The highlight_file() function is an inbuilt function in PHP which is used to highlight the syntax of file. The syntax is highlighted by using HTML tags. Syntax: highlight_file( $filename, $return ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: It is required parameter. It specifies the file whose content to be displayed.$return: It is optional and boolean parameter. Its default value is FALSE. If it is set to TRUE, instead of printing it out, this function will return the highlighted code as a string. Return Value: It returns TRUE on success, or returns FALSE on failure. If $return is set to TRUE, it will return the highlighted code as a string. Note: This function is available on PHP 4.0.0 and newer version.The colors used for highlighting the PHP syntax can be set with the ini_set() function or in the php.ini file.With this function entire file will be displayed, that may include sensitive data like passwords etc. Example 1: Save the given code using name server.php and run the program. php <!DOCTYPE html> <html> <body> <?php highlight_file("geeks.php"); ?> </body> </html> Output: Example 2: Save the given code using name geeks.php. php <?php // Loading XML document to $user $user = <<<XML <user> <username>Username</username> <name>Firstname Lastname</name> <phone>+91-9876543210</phone> <detail font-color="blue" font="awesome-fonts" font-size="24px"> Noida, India </detail> </user> XML; // Loading the string as simple xml object $xml = simplexml_load_string($user); // Print the children foreach($xml->children() as $child) { echo "child node:".$child."</br>"; } ?> Use the above filename in the below program to highlight the syntax. php <!DOCTYPE html> <html> <body> <?php highlight_file("geeks.php"); ?> </body> </html> Output: Reference: https://php.net/manual/en/function.highlight-file.php Comment More infoAdvertise with us Next Article PHP | highlight_file() Function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | hash_file( ) Function The hash_file() function is an inbuilt function in PHP which is used to generate a hash value using the contents of a given file. Syntax: string hash_file( $algo, $file, $raw_opt ) Parameters: This function accept three parameters as mention above and describe below. $algo: It is the required parame 2 min read PHP is_file( ) Function The is_file() function in PHP is an inbuilt function which is used to check whether the specified file is a regular file or not. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False. Syntax: bool is_file($file) 2 min read PHP | highlight_string() function The highlight_string() function is an inbuilt function in PHP which is used to highlight the text string. It returns output in HTML text format. Syntax: highlight_string( $string, $return ) Parameters: This function accepts two parameters as mentioned above and described below: $string: It is the re 2 min read PHP | filetype( ) Function The filetype() function in PHP is an inbuilt function which is used to return the file type of a specified file or a directory. The filetype() function accepts the filename as a parameter and returns one of the seven file types on success and False on failure. The seven possible return values of the 2 min read PHP file_get_contents() Function In this article, we will see how to read the entire file into a string using the file_get_contents() function, along with understanding their implementation through the example.The file_get_contents() function in PHP is an inbuilt function that is used to read a file into a string. The function uses 3 min read Like