cvs: /phpdoc/language control-structures.sgml

From: Date: Mon, 15 Nov 1999 04:39:17 +0000
Subject: cvs: /phpdoc/language control-structures.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-12548@lists.php.net to get a copy of this message
cslawi Sun Nov 14 23:39:17 1999 EDT Modified files: /phpdoc/language control-structures.sgml Log: Note that include( 'file.inc&varone=1&vartwo=2' ) isn't the way to do it. Seems to be people keep running into this one. Index: phpdoc/language/control-structures.sgml diff -u phpdoc/language/control-structures.sgml:1.6 phpdoc/language/control-structures.sgml:1.7 --- phpdoc/language/control-structures.sgml:1.6 Sun Nov 14 18:16:29 1999 +++ phpdoc/language/control-structures.sgml Sun Nov 14 23:39:16 1999 @@ -624,7 +624,32 @@ <programlisting> require 'header.inc'; </programlisting> - </informalexample></para></sect1> + </informalexample> + </para> + + + <para> + Please note that both <function>include</function> and + <function>require</function> actually pull the contents of the + target file into the calling script file itself; they do not call + the target via HTTP or anything like that. So any variable set in + the scope in which the inclusion happens will be available within + the included file automatically, since it has effectively become a + part of the calling file. + <informalexample> + <programlisting> +include( "file.inc?varone=1&amp;vartwo=2" ); /* Won't work. */ + +$varone = 1; +$vartwo = 2; +include( "file.inc" ); /* $varone and $vartwo will be available in file.inc */ + + </programlisting> + </informalexample> + + </para> + + </sect1> <sect1 id="function.include"> <title><literal>include</literal></title> @@ -686,6 +711,27 @@ When the file is evaluated, the parser begins in "HTML-mode" which will output the contents of the file until the first PHP start tag (&lt;?) is encountered.</para> + + <para> + Please note that both <function>include</function> and + <function>require</function> actually pull the contents of the + target file into the calling script file itself; they do not call + the target via HTTP or anything like that. So any variable set in + the scope in which the inclusion happens will be available within + the included file automatically, since it has effectively become a + part of the calling file. + <informalexample> + <programlisting> +include( "file.inc?varone=1&amp;vartwo=2" ); /* Won't work. */ + +$varone = 1; +$vartwo = 2; +include( "file.inc" ); /* $varone and $vartwo will be available in file.inc */ + + </programlisting> + </informalexample> + + </para> <para> See also <function>readfile</function>, <function>require</function>,

« previous php.dev (#12548) next »