Re: include() & require()

From: Date: Wed, 07 Mar 2001 15:18:56 +0000
Subject: Re: include() & require()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42907@lists.php.net to get a copy of this message
At 13:41 7/3/2001, Derek Sivers wrote:
Which is the main difference between include() and require() functions?
"include" is optional you can put it inside an "IF" like this: if (0) { /* THIS WILL NOT SHOW... */ include "optional_file.php"; } but "require" happens every time, even if it is inside an "IF" that does not happen. if (0) { /* THIS WILL SHOW ANYWAY... */ require "optional_file.php"; }
That's actually no longer true, in more recent versions of PHP (it used to be true). The only difference between include() and require() is that require() will bail out if it fails, whereas include() would not. Zeev

« previous php.general (#42907) next »