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:
Jesus M. Castagnetto 2000-07-08 00:06:32 +00:00
parent 2385029d30
commit 14d2ce1f6e

View file

@ -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 &quot;ForceType&quot; 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>
&lt;Location /source&gt;
ForceType application/x-httpd-php
&lt;/Location&gt;
</programlisting></informalexample>
</para>
<simpara>
And then make a file named &quot;source&quot; and put it in your
web root directory.
</simpara>
<para>
<programlisting role="php">
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Source Display&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY BGCOLOR=&quot;white&quot;&gt;
&lt;?php
$script = getenv (&quot;PATH_TRANSLATED&quot;);
if(!$script) {
echo &quot;&lt;BR&gt;&lt;B&gt;ERROR: Script Name needed&lt;/B&gt;&lt;BR&gt;&quot;;
} else {
if (ereg(&quot;(\.php|\.inc)$&quot;,$script)) {
echo &quot;&lt;H1&gt;Source of: $PATH_INFO&lt;/H1&gt;\n&lt;HR&gt;\n&quot;;
highlight_file($script);
} else {
echo &quot;&lt;H1&gt;ERROR: Only PHP or include script names are allowed&lt;/H1&gt;&quot;;
}
}
echo &quot;&lt;HR&gt;Processed: &quot;.date(&quot;Y/M/d H:i:s&quot;,time());
?&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</programlisting>
</para>
<simpara>
Then you can use an URL like the one below to display a colorized
version of a script located in &quot;/path/to/script.php&quot;
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