Re: note 11713 added to require

From: Date: Sat, 03 Mar 2001 19:12:17 +0000
Subject: Re: note 11713 added to require
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-11821@lists.php.net to get a copy of this message
See require_once/include_once, no need to use a define(), and read again about the difference of require/include in the manual and/or in the PHP FAQTS site (www.php.net/support.php) Your note will be removed --- omnivore@eol.ca wrote: > I have a file, test1.php: > > <? > require("testInclude.php"); > include("test2.php"); > ?> > > test2.php looks like this: > > <? > require("testInclude.php"); > echo "done"; > ?> > > If testInclude.php includes a function definition: > > <? > function nothing(){ > #misc code > } > ?> > > Then the operation fails with the message: > > Fatal error: Cannot redeclare nothing() in Unknown > on line 3 > > Indicating that require() is called repeatedly if > the calls are on separate lines. In practical terms, > this means I have to include a define() in the > included file which is a flag to indicate that the > include has happened already. > > Each page that includes the testInclude.php page > then has to check if this value is defined and use a > conditional include() instead of require()... The > ideal solution would be a php command that would > include() the file only if it had not previously > been included. > > I thought that this is what require did, but it does > not. Given the similarities between require() and > include(), would this not be a good direction to > take require() in? > > http://www.php.net/manual/en/function.require.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto <jmcastagnetto@php.net> __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/

« previous php.notes (#11821) next »