How to use highlight string in PHP

In this article I will explain how highlight_string function can be used in PHP.
  • 1452

highlight_string() Function

This function outputs a string with the PHP syntax highlighted.

Note-colors used for highlighting can be set in the php.ini file or with the ini_set() function.

Syntax

highlight_string(string,return)

 

 Parameter  Description
 string  Required. Specifies the string to highlight
 return  Optional. 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.

Example

<html>
<body>
<?php
highlight_string("Hello world! <?php phpinfo(); ?>");
?>
</body>
</html>

 

Output


hilight-string-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.