Home »
Imported messages »
comp.lang.php »
Use of Includes
Re: Use of Includes [message #170908 is a reply to message #170907] |
Tue, 07 December 2010 15:05 |
Captain Paralytic
Messages: 204 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Dec 7, 2:55 pm, Bill Braun <m...@privacy.net> wrote:
> New to PHP.
>
> Have searched for answer without finding anything that seems to address
> it, save perhaps for situations where the script writes HTML markup
> before the header is called.
>
> When would it be preferable/required to chain scripts one to the next
> rather than use includes? (The question could be reversed, also.)
>
> Chaining:
>
> [php] // script1.php
> code;
> header("location: script2.php");
> [endphp]
>
> [php] // script2.php
> code;
> header("location: script3.php");
> [endphp]
>
> [php] // script3.php
> code;
> [endphp]
>
> Include:
>
> [php]
> // scriptname: script1.php
> code;
> include 'script2.php';
> include 'script3.php';
> [endphp]
>
> Bill B
These do completely different things, so the question cannot really be
answered.
The includes cause all the scripts to be executed and then output is
sent (usually to a browser). Any global variables that are present in
script1 will have the same values in scripts 2 and 3.
The redirection using headers is supposed to be with the full url
thus:
header("location: http://www.example.com/script2.php");
header("location: http://www.example2.com/script3.php");
Script 2 knows nothing about script 1 likewise script 3. Indeed as in
my example, they could be on different servers.
You are comparing apples and pears.
|
|
|
Goto Forum:
Current Time: Thu Nov 28 19:39:06 GMT 2024
Total time taken to generate the page: 0.04091 seconds