phpgroupware-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Phpgroupware-developers] Discussion: include/require statements


From: Dave Hall
Subject: Re: [Phpgroupware-developers] Discussion: include/require statements
Date: Tue, 10 May 2005 17:42:32 +1000

On Tue, 2005-05-10 at 09:12 +0200, Kai Hofmann wrote:
> Something for HEAD discussion:
> 
> to me it looks like it will be useful to change all
> 
> include(),include_once(),require()
> 
> statements to
> 
> require_once()
> 
> This will stop including one file more than one time.
> Also to my best knowledge "require" fits more our needs,
> because include will not produce an error, when it can not find
> a file, but the code that depends on such a files content will
> then crash later ...
> So it would be best to stop at the "require" and not at the
> missing code.
> 
> 
> Any opinions/statements to this?

I support the use of it.  Although I mainly use include_once from habit
I have not issue with using require_once.  The old include/require
statements are a hang over from php3.  The use of includes/requires
should be quite limited as people should be using
createObject/ExecMethod

I think there are some occassions (setup and header.inc.php) where using
something like the example below is more appropriate than just dumping
the user with an error.

if ( !include_once('file.php') )
{
        die('Your install is fux0r contact your sysadmin');
}

btw from TFM 
<quote source="http://php.net/include";>
The two constructs are identical in every way except how they handle
failure. include() produces a Warning while require() results in a Fatal
Error.
</quote>

A warning is an error type, and it is displayed/logged as such.

Cheers

Dave

-- 
Dave Hall (aka skwashd)
API Coordinator
phpGroupWare
-------------------------------------------------------------------------
Do you think if Bill Gates got laid in high school, do you think there'd 
be a Microsoft?  Of course not.
Underwear Goes Inside The Pants by Lazy Boy





reply via email to

[Prev in Thread] Current Thread [Next in Thread]