don't use .inc extension in examples

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@65520 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
jim winstead 2001-12-17 23:00:19 +00:00
parent 83952b5075
commit 02e9b3e175

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.46 $ -->
<!-- $Revision: 1.47 $ -->
<chapter id="control-structures">
<title>Control Structures</title>
@ -1033,7 +1033,7 @@ print_r (profile (TRUE));
<informalexample>
<programlisting role="php">
<![CDATA[
require ('header.inc');
require ('header.php');
]]>
</programlisting>
</informalexample>
@ -1130,7 +1130,7 @@ require ("file.php"); /* Works. */
<informalexample>
<programlisting role="php">
<![CDATA[
$files = array ('first.inc', 'second.inc', 'third.inc');
$files = array ('first.php', 'second.php', 'third.php');
for ($i = 0; $i < count($files); $i++) {
include $files[$i];
}
@ -1193,7 +1193,7 @@ if ($condition) {
<title><function>include</function> in PHP 3 and PHP 4</title>
<para>
Assume the existence of the following file (named
<filename>test.inc</filename>) in the same directory as the main
<filename>test.php</filename>) in the same directory as the main
file:
<programlisting role="php">
<![CDATA[
@ -1213,7 +1213,7 @@ echo "After the return <br>\n";
<programlisting role="php">
<![CDATA[
<?php
$retval = include ('test.inc');
$retval = include ('test.php');
echo "File returned: '$retval'<br>\n";
?>
]]>
@ -1235,7 +1235,7 @@ File returned: '27'
<programlisting role="php">
<![CDATA[
<?php
include ('test.inc');
include ('test.php');
echo "Back in main.html<br>\n";
?>
]]>
@ -1258,7 +1258,7 @@ Parse error: parse error in /home/torben/public_html/phptest/main.html on line 5
<para>
The above parse error is a result of the fact that the
<literal>return</literal> statement is enclosed in a non-function
block within <filename>test.inc</filename>. When the return is
block within <filename>test.php</filename>. When the return is
moved outside of the block, the output is:
<screen>
Before the return
@ -1336,9 +1336,9 @@ include ("file.php"); /* Works. */
</para>
<para>
For example, if you create the following 2 include files
<literal>utils.inc</literal> and <literal>foolib.inc</literal>
<literal>utils.php</literal> and <literal>foolib.php</literal>
<example>
<title>utils.inc</title>
<title>utils.php</title>
<programlisting role="php">
<![CDATA[
<?php
@ -1353,11 +1353,11 @@ function goodTea()
</programlisting>
</example>
<example>
<title>foolib.inc</title>
<title>foolib.php</title>
<programlisting role="php">
<![CDATA[
<?php
require ("utils.inc");
require ("utils.php");
function showVar($var)
{
if (PHPVERSION == 4) {
@ -1378,12 +1378,12 @@ function showVar($var)
<programlisting role="php">
<![CDATA[
<?php
require("foolib.inc");
require("foolib.php");
/* the following will generate an error */
require("utils.inc");
require("utils.php");
$foo = array("1",array("complex","quaternion"));
echo "this is requiring utils.inc again which is also\n";
echo "required in foolib.inc\n";
echo "this is requiring utils.php again which is also\n";
echo "required in foolib.php\n";
echo "Running goodTea: ".goodTea()."\n";
echo "Printing foo: \n";
showVar($foo);
@ -1399,21 +1399,21 @@ showVar($foo);
GLOBALS ARE NICE
GLOBALS ARE NICE
Fatal error: Cannot redeclare goodTea() in utils.inc on line 5
Fatal error: Cannot redeclare goodTea() in utils.php on line 5
]]>
</screen>
</informalexample>
By modifying <literal>foolib.inc</literal> and
By modifying <literal>foolib.php</literal> and
<literal>cause_errror_require.php</literal>
to use <function>require_once</function>
instead of <function>require</function> and renaming the
last one to <literal>avoid_error_require_once.php</literal>, we have:
<example>
<title>foolib.inc (fixed)</title>
<title>foolib.php (fixed)</title>
<programlisting role="php">
<![CDATA[
...
require_once("utils.inc");
require_once("utils.php");
function showVar($var)
{
...
@ -1425,8 +1425,8 @@ function showVar($var)
<programlisting role="php">
<![CDATA[
...
require_once("foolib.inc");
require_once("utils.inc");
require_once("foolib.php");
require_once("utils.php");
$foo = array("1",array("complex","quaternion"));
...
]]>
@ -1437,8 +1437,8 @@ $foo = array("1",array("complex","quaternion"));
<screen>
<![CDATA[
GLOBALS ARE NICE
this is requiring globals.inc again which is also
required in foolib.inc
this is requiring globals.php again which is also
required in foolib.php
Running goodTea: Oolong tea tastes good!
Printing foo:
Array