search for in the  
<get_browserhighlight_string>
Last updated: Thu, 19 May 2005

highlight_file

(PHP 4, PHP 5)

highlight_file -- Syntax highlighting of a file

Description

mixed highlight_file ( string filename [, bool return] )

The highlight_file() function prints out a syntax highlighted version of the code contained in filename using the colors defined in the built-in syntax highlighter for PHP.

If the second parameter return is set to TRUE then highlight_file() will return the highlighted code as a string instead of printing it out. If the second parameter is not set to TRUE then highlight_file() will return TRUE on success, FALSE on failure.

Note: The return parameter became available in PHP 4.2.0. Before this time it behaved like the default, which is FALSE

Note: Since PHP 4.2.1 this function is also affected by safe_mode and open_basedir.

Caution

Care should be taken when using the highlight_file() function to make sure that you do not inadvertently reveal sensitive information such as passwords or any other type of information that might create a potential security risk.

Many servers are configured to automatically highlight files with a phps extension. For example, example.phps when viewed will show the syntax highlighted source of the file. To enable this, add this line to the httpd.conf:

AddType application/x-httpd-php-source .phps

See also highlight_string().



User Contributed Notes
highlight_file
Vlad Alexa Mancini valexa at nextcode dot org
21-Feb-2005 01:19
Here is a small bash script that you can type at the console to make recursive symbolic .phps links for all your .php files starting at your curent directory

for f in `find -name '*.php'`; do ln -s `basename $f` $f's'; done

NOTE: You doubtedly want to do this at / as it will make such symlinks for all the php files on your filesystem

NOTE: This places the symlinks in the same directory as the php file that they are simlinking

And a simpler one that is not recursive and does the same thing but only for the php files in your current directory

for f in *.php; do ln -s $f $f's'; done
aidan at php dot net
26-Sep-2004 10:29
To add line numbers to source code, with optional function linking, use the below function:

http://aidan.dotgeek.org/lib/?file=function.highlight_file_linenum.php

A much more thorough and smarter, though slower version is here:

http://aidan.dotgeek.org/lib/?file=PHP_Highlight.php
csst0266 at cs dot uoi dot gr
13-Aug-2004 11:42
Here is a simple, yet useful, tip... Issuing the following command under a Unix-like OS:

ln -s your_script.php your_script.phps

Will result in the creation of a symbolic link (called your_script.phps) to the source code (your_script.php). This way you have (apart from the source code .php) the highlighted version of your script (.phps) accessible via your web browser.
zan at stargeek dot com
09-Jan-2003 12:24
here's how to use highlight_file to create a browseable archive of php scripts http://www.stargeek.com/scripts.php?script=7&cat=blog

<get_browserhighlight_string>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT