mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Whitespace
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@271987 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
0a309a5f0d
commit
bca6c27158
2 changed files with 65 additions and 63 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
|
||||
<sect1 xml:id="function.include-once" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title><function>include_once</function></title>
|
||||
|
@ -37,20 +37,20 @@
|
|||
</para>
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Be aware, that the behaviour of <function>include_once</function>
|
||||
and <function>require_once</function> may not be what you expect
|
||||
on a non case sensitive operating system (such as Windows).
|
||||
<example>
|
||||
<title><function>include_once</function> is case insensitive on Windows</title>
|
||||
<programlisting role="php">
|
||||
<para>
|
||||
Be aware, that the behaviour of <function>include_once</function>
|
||||
and <function>require_once</function> may not be what you expect
|
||||
on a non case sensitive operating system (such as Windows).
|
||||
<example>
|
||||
<title><function>include_once</function> is case insensitive on Windows</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include_once "a.php"; // this will include a.php
|
||||
include_once "A.php"; // this will include a.php again on Windows! (PHP 4 only)
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
This behaviour changed in PHP 5 - the path is normalized first so that
|
||||
<filename>C:\PROGRA~1\A.php</filename> is realized the same as
|
||||
|
@ -58,7 +58,9 @@ include_once "A.php"; // this will include a.php again on Windows! (PHP 4 only)
|
|||
</para>
|
||||
</note>
|
||||
</para>
|
||||
|
||||
&warn.no-win32-fopen-wrapper;
|
||||
|
||||
<para>
|
||||
See also <function>include</function>,
|
||||
<function>require</function>, <function>require_once</function>,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
|
||||
<sect1 xml:id="function.include" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title><function>include</function></title>
|
||||
|
@ -8,17 +8,17 @@
|
|||
the specified file.
|
||||
</simpara>
|
||||
<simpara>
|
||||
The documentation below also applies to <function>require</function>.
|
||||
The two constructs are identical in every way except how they handle
|
||||
failure. They both produce a
|
||||
<link linkend="errorfunc.constants.errorlevels.e-warning">Warning</link>, but <function>require</function>
|
||||
results in a <link linkend="errorfunc.constants.errorlevels.e-error">Fatal Error</link>.
|
||||
In other words, use <function>require</function> if you want
|
||||
a missing file to halt processing of the page. <function>include</function> does
|
||||
not behave this way, the script will continue regardless. Be sure to have an
|
||||
appropriate <link linkend="ini.include-path">include_path</link> setting as well.
|
||||
Be warned that parse error in included file doesn't cause processing halting
|
||||
in PHP versions prior to PHP 4.3.5. Since this version, it does.
|
||||
The documentation below also applies to <function>require</function>.
|
||||
The two constructs are identical in every way except how they handle
|
||||
failure. They both produce a
|
||||
<link linkend="errorfunc.constants.errorlevels.e-warning">Warning</link>, but <function>require</function>
|
||||
results in a <link linkend="errorfunc.constants.errorlevels.e-error">Fatal Error</link>.
|
||||
In other words, use <function>require</function> if you want
|
||||
a missing file to halt processing of the page. <function>include</function> does
|
||||
not behave this way, the script will continue regardless. Be sure to have an
|
||||
appropriate <link linkend="ini.include-path">include_path</link> setting as well.
|
||||
Be warned that parse error in included file doesn't cause processing halting
|
||||
in PHP versions prior to PHP 4.3.5. Since this version, it does.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Files for including are first looked for in each include_path entry
|
||||
|
@ -33,18 +33,18 @@
|
|||
is looked only in the current working directory.
|
||||
</simpara>
|
||||
<simpara>
|
||||
When a file is included, the code it contains inherits the
|
||||
<link linkend="language.variables.scope">variable scope</link> of the
|
||||
line on which the include occurs. Any variables available at that line
|
||||
in the calling file will be available within the called file, from that
|
||||
point forward.
|
||||
However, all functions and classes defined in the included file have the
|
||||
global scope.
|
||||
When a file is included, the code it contains inherits the
|
||||
<link linkend="language.variables.scope">variable scope</link> of the
|
||||
line on which the include occurs. Any variables available at that line
|
||||
in the calling file will be available within the called file, from that
|
||||
point forward.
|
||||
However, all functions and classes defined in the included file have the
|
||||
global scope.
|
||||
</simpara>
|
||||
<para>
|
||||
<example>
|
||||
<title>Basic <function>include</function> example</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Basic <function>include</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
vars.php
|
||||
<?php
|
||||
|
@ -65,22 +65,22 @@ echo "A $color $fruit"; // A green apple
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
If the include occurs inside a function within the calling file,
|
||||
then all of the code contained in the called file will behave as
|
||||
though it had been defined inside that function. So, it will follow
|
||||
the variable scope of that function.
|
||||
An exception to this rule are <link
|
||||
linkend="language.constants.predefined">magic constants</link> which are
|
||||
evaluated by the parser before the include occurs.
|
||||
If the include occurs inside a function within the calling file,
|
||||
then all of the code contained in the called file will behave as
|
||||
though it had been defined inside that function. So, it will follow
|
||||
the variable scope of that function.
|
||||
An exception to this rule are <link
|
||||
linkend="language.constants.predefined">magic constants</link> which are
|
||||
evaluated by the parser before the include occurs.
|
||||
</simpara>
|
||||
<para>
|
||||
<example>
|
||||
<example>
|
||||
<title>Including within functions</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -107,25 +107,25 @@ echo "A $color $fruit"; // A green
|
|||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
When a file is included, parsing drops out of PHP mode and
|
||||
into HTML mode at the beginning of the target file, and resumes
|
||||
again at the end. For this reason, any code inside the target
|
||||
file which should be executed as PHP code must be enclosed within
|
||||
<link linkend="language.basic-syntax.phpmode">valid PHP start
|
||||
and end tags</link>.
|
||||
When a file is included, parsing drops out of PHP mode and
|
||||
into HTML mode at the beginning of the target file, and resumes
|
||||
again at the end. For this reason, any code inside the target
|
||||
file which should be executed as PHP code must be enclosed within
|
||||
<link linkend="language.basic-syntax.phpmode">valid PHP start
|
||||
and end tags</link>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
If "<link linkend="ini.allow-url-fopen">URL fopen wrappers</link>"
|
||||
are enabled in PHP (which they are in the default configuration),
|
||||
you can specify the file to be included using a URL (via HTTP or
|
||||
other supported wrapper - see <xref linkend="wrappers"/> for a list
|
||||
of protocols) instead of a local pathname. If the target server interprets
|
||||
the target file as PHP code, variables may be passed to the included
|
||||
file using a URL request string as used with HTTP GET. This is
|
||||
not strictly speaking the same thing as including the file and having
|
||||
it inherit the parent file's variable scope; the script is actually
|
||||
being run on the remote server and the result is then being
|
||||
included into the local script.
|
||||
If "<link linkend="ini.allow-url-fopen">URL fopen wrappers</link>"
|
||||
are enabled in PHP (which they are in the default configuration),
|
||||
you can specify the file to be included using a URL (via HTTP or
|
||||
other supported wrapper - see <xref linkend="wrappers"/> for a list
|
||||
of protocols) instead of a local pathname. If the target server interprets
|
||||
the target file as PHP code, variables may be passed to the included
|
||||
file using a URL request string as used with HTTP GET. This is
|
||||
not strictly speaking the same thing as including the file and having
|
||||
it inherit the parent file's variable scope; the script is actually
|
||||
being run on the remote server and the result is then being
|
||||
included into the local script.
|
||||
</simpara>
|
||||
&warn.no-win32-fopen-wrapper;
|
||||
<para>
|
||||
|
@ -214,7 +214,7 @@ if ((include 'vars.php') == 'OK') {
|
|||
<para>
|
||||
<example>
|
||||
<title><function>include</function> and the <function>return</function> statement</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
return.php
|
||||
<?php
|
||||
|
@ -245,7 +245,7 @@ echo $bar; // prints 1
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
|
@ -273,7 +273,7 @@ echo $bar; // prints 1
|
|||
<para>
|
||||
<example>
|
||||
<title>Using output buffering to include a PHP file into a string</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$string = get_include_contents('somefile.php');
|
||||
|
@ -291,7 +291,7 @@ function get_include_contents($filename) {
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue