PHP – Highlighted PHP code in output

highlight_string is use to highlight the given php code use the color defined in built in syntax.

This function has two parameter:
First: the string
Second: the bool ture or false
If return is set to TRUE,  returns the highlighted code as a string instead of printing it out

$string = "<?php echo 'hi' ?>";
$output = highlight_string($string, true);
echo $output;
Another code example to get the contents from a file and then highlight the php code: 
highlight_string(file_get_contents('test.php' ), false);

The code will get the contents of the test.php file and output them.

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

1 Comment

  1. avatarDilshad

    This is one of the best site i had ever seen
    which gives simple and easy way to understand
    and also provide much of the information which required
    for a php developer to solve their problems.
    great job

Leave a Comment

Your email address will not be published. Required fields are marked *