Re: Programming Tips and Tricks
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Programming Tips and Tricks

From: Andy Hassall <andy@andyh.co.uk>
Date: Wed Jul 27 2005 - 00:15:38 CEST

On Tue, 26 Jul 2005 22:09:42 GMT, "Don Freeman" <freemand@sonic.net> wrote:

>"include_once() 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.":
>----
>So now I get to ask an extremely dumb question...
>
>Why would you include the same file multiple times in the same file anyway?

 Usually, when you want the output produced by that file printed multiple
times.

stuff.php:
<?php print "The value is: $var<br>"; ?>

index.php:
<?php
$var = 1;
include('stuff.php');

$var = 2;
include('stuff.php');

$var = 3;
include('stuff.php');
?>

 This is a contrived example, but sometimes it's what you want.

-- 
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Received on Mon Oct 17 21:19:39 2005