★ wanayoo — archive 1999 http://www.php.net/manual/hu/function.highlight-file.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Máshova nem sorolható
Quick Reference
English version of this pageGerman version of this pageJapanese version of this page
Máshova nem sorolható
* connection_aborted
* connection_status
* connection_timeout
* define
* defined
* die
* eval
* exit
* func_get_arg
* func_get_args
* func_num_args
* function_exists
* get_browser
* ignore_user_abort
* iptcparse
* leak
* pack
* register_shutdown_function
* serialize
* sleep
* uniqid
* unpack
* unserialize
* usleep
* highlight_string
* highlight_file
* show_source
Manual: highlight_file
View the source code for this pageSearch the site



Previous page
 highlight_string
 Updated
Sat, 12 Aug 2000
show_source 
Next page


highlight_file

(PHP4 )

highlight_file -- Syntax highlighting of a file

Description

void highlight_file (string filename)

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

Példa 1. Creating a source highlighting URL

To setup a URL that can code hightlight any script that you pass to it, we will make use of the "ForceType" directive in Apache to generate a nice URL pattern, and use the function highlight_file() to show a nice looking code list.

In your httpd.conf you can add the following:


<Location /source>
    ForceType application/x-httpd-php
</Location>
       

And then make a file named "source" and put it in your web root directory.


<HTML>
<HEAD>
<TITLE>Source Display</TITLE>
</HEAD>
<BODY BGCOLOR="white">
<?php
    $script = getenv ("PATH_TRANSLATED");
    if(!$script) {
        echo "<BR><B>ERROR: Script Name needed</B><BR>";
    } else {
        if (ereg("(\.php|\.inc)$",$script)) {
            echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n";
            highlight_file($script);
        } else {
            echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; 
        }
    }
    echo "<HR>Processed: ".date("Y/M/d H:i:s",time());
?>
</BODY>
</HTML>
       

Then you can use an URL like the one below to display a colorized version of a script located in "/path/to/script.php" in your web site.


http://your.server.com/source/path/to/script.php
  

See also highlight_string(), show_source().


 About Notes


Previous page
 highlight_string
 Updated
Sat, 12 Aug 2000
show_source 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.