Syntax:highlight_file ($filename, $return)
Parameters:this function takes two parameters as specified above and described below:
- $filename:required. It specifies the file whose contents will be displayed.
- $return:This is an optional and boolean parameter. Its default value is - FALSE. If set to TRUE, instead of printing it, this function will return the highlighted code as a string.
Return Value:returns TRUE on success or FALSE on failures. If $return is TRUE, it will return the highlighted code as a string.
Notes : - This function is available in PHP 4.0.0 and newer version.
- The colors used for PHP syntax highlighting can be set using the ini_set() function or in the php.ini file.
- This function will display the entire file, which may include sensitive data such as passwords, etc.
Example 1.Save this code using the name
server.php and run the program.
highlight_file (
"engineer.php"
) ;
?>
< / html >
Output: Example 2:Save this code using the name engineer. php . < tbody>
// Load XML document into $user
$user
= < < < XML
< user >
< username > Username < / username >
< name > Firstname Lastname < / name >
+ 91-9876543210 < / phone >
< detail font-color =
"blue"
font =
"awsome-fonts"
font-size =
"24px"
>
Noida, India
< / detail >
< / user >
XML;
// Load the string as a simple xml object
$xml
= simplexml_load_string (
$user
);
// Print children
foreach
(
$xml
-> children()
as
$child
) {
echo
"child node:"
.
$child
.
"
"
;
}
?>
Use the above filename in the program below to highlight syntax.
highlight_file (
"engineer.php"
) ;
?>
< / html >
Output: Link: https://php.net/manual/en/function.highlight-file.php