cvs: phpdoc /en/language/control-structures require-once.xml require.xml

From: Date: Sat, 27 Dec 2008 06:45:07 +0000
Subject: cvs: phpdoc /en/language/control-structures require-once.xml require.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2840@lists.php.net to get a copy of this message
philip Sat Dec 27 06:45:07 2008 UTC Modified files: /phpdoc/en/language/control-structures require.xml require-once.xml Log: Remove most require*() documentation as it's identical to include*() except for the E_ERROR on failure. And refer to include*(). http://cvs.php.net/viewvc.cgi/phpdoc/en/language/control-structures/require.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/language/control-structures/require.xml diff -u phpdoc/en/language/control-structures/require.xml:1.1 phpdoc/en/language/control-structures/require.xml:1.2 --- phpdoc/en/language/control-structures/require.xml:1.1 Sat Dec 27 01:35:49 2008 +++ phpdoc/en/language/control-structures/require.xml Sat Dec 27 06:45:07 2008 @@ -1,76 +1,20 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 xml:id="function.require" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title><function>require</function></title> - - <simpara> - The <function>require</function> statement includes and evaluates - the specific file. - </simpara> - <simpara> - <function>require</function> includes and evaluates a specific file. - Detailed information on how this inclusion works is described in the - documentation for <function>include</function>. - </simpara> - <simpara> - <function>require</function> and <function>include</function> - 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, don't hesitate to 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. - </simpara> + <para> - <example> - <title>Basic <function>require</function> examples</title> - <programlisting role="php"> -<![CDATA[ -<?php - -require 'prepend.php'; - -require $somefile; - -require ('somefile.txt'); - -?> -]]> - </programlisting> - </example> + <function>require</function> is identical to <function>include</function> + except upon failure it will produce a fatal <constant>E_ERROR</constant> + level error. In other words, it will halt the script whereas + <function>include</function> only emits a warning + (<constant>E_WARNING</constant>) which allows the script to continue. </para> - <simpara> - See the <function>include</function> documentation for more examples. - </simpara> <para> - <note> - <simpara> - Prior to PHP 4.0.2, the following applies: <function>require</function> - will always attempt to read the target file, even if the line it's on - never executes. The conditional statement won't affect - <function>require</function>. However, if the line on which the - <function>require</function> occurs is not executed, neither will any of - the code in the target file be executed. Similarly, looping structures - do not affect the behaviour of <function>require</function>. Although - the code contained in the target file is still subject to the loop, the - <function>require</function> itself happens only once. - </simpara> - </note> + See the <function>include</function> documentation for how this works. </para> - - &note.language-construct; - - &warn.no-win32-fopen-wrapper; - - <simpara> - See also <function>include</function>, <function>require_once</function>, - <function>include_once</function>, <function>get_included_files</function>, - <function>eval</function>, <function>file</function>, <function>readfile</function>, - <function>virtual</function> and <link linkend="ini.include-path">include_path</link>. - </simpara> + </sect1> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/language/control-structures/require-once.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/language/control-structures/require-once.xml diff -u phpdoc/en/language/control-structures/require-once.xml:1.1 phpdoc/en/language/control-structures/require-once.xml:1.2 --- phpdoc/en/language/control-structures/require-once.xml:1.1 Sat Dec 27 01:35:49 2008 +++ phpdoc/en/language/control-structures/require-once.xml Sat Dec 27 06:45:07 2008 @@ -1,72 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 xml:id="function.require-once" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title><function>require_once</function></title> <para> - The <function>require_once</function> statement includes and evaluates - the specified file during the execution of the script. - This is a behavior similar to the <function>require</function> statement, - with the only difference being that if the code from a file has already - been included, it will not be included again. See the documentation for - <function>require</function> for more information on how this statement - works. + The <function>require_once</function> statement is identical to + <function>require</function> except PHP will check if the file has + already been included, and if so, not include (require) it again. </para> <para> - <function>require_once</function> should be used in cases where - the same file might be included and evaluated more than once during a - particular execution of a script, and you want to be sure that it is - included exactly once to avoid problems with function redefinitions, - variable value reassignments, etc. - </para> - <para> - For examples on using <function>require_once</function> and - <function>include_once</function>, look at the - <link xlink:href="&url.php.pear;">PEAR</link> code included in the - latest PHP source code distributions. - </para> - <para> - Return values are the same as with <function>include</function>. If the file - was already included, this function returns &true; - </para> - <para> - <note> - <para> - <function>require_once</function> was added in PHP 4.0.1 - </para> - </note> - </para> - <para> - <note> - <para> - Be aware, that the behaviour of <function>require_once</function> - and <function>include_once</function> may not be what you expect - on a non case sensitive operating system (such as Windows). - <example> - <title><function>require_once</function> is case insensitive on Windows</title> - <programlisting role="php"> -<![CDATA[ -<?php -require_once "a.php"; // this will include a.php -require_once "A.php"; // this will include a.php again on Windows! (PHP 4 only) -?> -]]> - </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 - <filename>C:\Program Files\a.php</filename> and the file is required just once. - </para> - </note> - </para> - &warn.no-win32-fopen-wrapper; - <para> - See also <function>require</function>, - <function>include</function>, <function>include_once</function>, - <function>get_required_files</function>, - <function>get_included_files</function>, <function>readfile</function>, and - <function>virtual</function>. + See the <function>include_once</function> documentation for information + about the <literal>_once</literal> behaviour, and how it differs from + its non <literal>_once</literal> siblings. </para> + </sect1> <!-- Keep this comment at the end of the file

« previous php.doc.cvs (#2840) next »