Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP show_source() Function

PHP show_source() Function

PHP Misc Reference Manual PHP Misc Reference Manual

Example

PHP syntax highlighting of a test file ("test.php"):

The browser output of the above code is as follows (depending on the contents of the file):

The HTML output of the above code is as follows (view source):



echo ("test.php");
?>

Run Example »


Definition and Usage

The show_source() function performs PHP syntax highlighting on a file. The syntax is highlighted using HTML tags.

The colors used for highlighting can be set in the php.ini file or by calling the ini_set() function.

show_source() is highlight_file() is an alias of.

**Note:** When using this function, the entire file is displayed, including passwords and other sensitive information!


Syntax

show_source(

filename,return

)

Parameters Description
filename Required. Specifies the file to display.
return Optional. If set to TRUE, this function returns the highlighted code as a string instead of outputting it directly. Default is FALSE.

Technical Details

Return Value: If both the return If the parameter is set to TRUE, this function returns the highlighted code as a string instead of outputting it directly. Otherwise, it returns TRUE on success and FALSE on failure.
PHP Version: 4+
Changelog: Since PHP 4.2.1 this function is also affected by safe_mode and open_basedir. However, safe_mode was removed in PHP 5.4.
 在 PHP 4.2.0 中新增了 return 参数。 |

PHP Misc Reference Manual PHP Misc Reference Manual