mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Added documentation for highlight_string(), highlight_file() and its
alias show_source() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@27845 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
2385029d30
commit
14d2ce1f6e
1 changed files with 142 additions and 0 deletions
|
@ -1121,6 +1121,148 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp)) {
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.highlight_string">
|
||||
<refnamediv>
|
||||
<refname>highlight_string</refname>
|
||||
<refpurpose>Syntax highlighting of a string</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>highlight_string</function></funcdef>
|
||||
<paramdef>string <parameter>str</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
The <function>highlight_string</function> function prints out a syntax
|
||||
higlighted version of <parameter>str</parameter> using the colors defined
|
||||
in the built-in syntax highlighter for PHP.
|
||||
</simpara>
|
||||
<simpara>
|
||||
See also <function>higlight_file</function>,
|
||||
<function>show_source</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.highlight_file">
|
||||
<refnamediv>
|
||||
<refname>highlight_file</refname>
|
||||
<refpurpose>Syntax highlighting of a file</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>highlight_file</function></funcdef>
|
||||
<paramdef>string <parameter>filename</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
The <function>highlight_file</function> function prints out a syntax
|
||||
higlighted version of the code contained in <parameter>filename</parameter>
|
||||
using the colors defined in the built-in syntax highlighter for PHP.
|
||||
</simpara>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a source highlighting URL</title>
|
||||
<simpara>
|
||||
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 <function>highlight_file</function> to show a nice looking
|
||||
code list.
|
||||
</simpara>
|
||||
<simpara>
|
||||
In your httpd.conf you can add the following:
|
||||
</simpara>
|
||||
<para>
|
||||
<informalexample><programlisting>
|
||||
<Location /source>
|
||||
ForceType application/x-httpd-php
|
||||
</Location>
|
||||
</programlisting></informalexample>
|
||||
</para>
|
||||
<simpara>
|
||||
And then make a file named "source" and put it in your
|
||||
web root directory.
|
||||
</simpara>
|
||||
<para>
|
||||
<programlisting role="php">
|
||||
<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>
|
||||
</programlisting>
|
||||
</para>
|
||||
<simpara>
|
||||
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.
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
http://your.server.com/source/path/to/script.php
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</simpara>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
See also <function>highlight_string</function>,
|
||||
<function>show_source</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.show_source">
|
||||
<refnamediv>
|
||||
<refname>show_source</refname>
|
||||
<refpurpose>Syntax highlighting of a file</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>show_source</function></funcdef>
|
||||
<paramdef>string <parameter>filename</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
The <function>show_source</function> function prints out a syntax
|
||||
higlighted version of the code contained in <parameter>filename</parameter>
|
||||
using the colors defined in the built-in syntax highlighter for PHP.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
This function is an alias for the function
|
||||
<function>highlight_file</function>
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
See also <function>highlight_string</function>,
|
||||
<function>highlight_file</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
</reference>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue