>How can you not allow it to fail? if you go to >require('/tmp/the_file_that_does_not_exist'), how do you handle that >successfully and still finish the script?
>This is the claim that Joe and I's co-worker claimed. Above was my >example back to him.
>That was the end of the conversation.
>I do understand what you are saying, but it is misleading when you say >it is not allowed to fail -- it implies (apparently to our co-worker) >that even if a file doesn't exist, somehow his code was magically >going to work anyway. This seems to be what is probably most >misunderstood.
>-jeremy brand
> http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more >--------------------------------------------------------------------- > We cannot do everything at once, but we can do something at once. > -- Calvin Coolidge
>On Tue, 14 Nov 2000, Andi Gutmans wrote:
> > Date: Tue, 14 Nov 2000 07:16:22 +0200 > > From: Andi Gutmans <a...@zend.com> > > To: Mark Peoples <gas...@gascairlines.com>, > "'PHP General List. (E-mail)'" <php-gene...@lists.php.net> > > Subject: RE: [PHP] Require() vs Include()
> > In the latest versions of PHP 4.0 (I think since 4.0.2) require() and > > include() behave exactly the same *except* that a require() is not allowed > > to fail. So feel free to use any of these two, they are the same speed. > The > > implementation of require() used to be different but both for consistency > > reasons and due to the fact that the old require() wasn't faster than the > > include() as it was supposed to be we chose consistency.
> > Andi
> > At 09:55 PM 11/13/00 -0700, Mark Peoples wrote: > > >Hi Maxim, > > > Suppose you have this:
> > >Well, my cat, Violet <g>, has black fur, so the 2nd condition is > valid, the > > >1st is false. However, require() is executed regardless, so, the output of > > >test.php is:
> > >why to use require() when include() works just as well and even better > when > > >there are some conditions like if{} ?
> > >I ask it because although I read many articles on this issue I found no > > >reason for myself to use require() instead of include() and I have driven > > >some huge projects in PHP.
> > >Why do I see these hardcore PHP gurus writing PHPLIB, mySQLadmin and > > >examples in their articles using require() where include() would fit > just as > > >perfect?
> > >WHERE THE TRIIIICK?
> > >It escapes from me ...
> > >Thanks.
> > >Maxim Maletsky - ma...@j-door.com <mailto:ma...@j-door.com> > > >Webmaster, J-Door.com / J@pan Inc. > > >LINC Media, Inc. > > >TEL: 03-3499-2175 x 1271 > > >FAX: 03-3499-3109
> > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net > > For additional commands, e-mail: php-general-h...@lists.php.net > > To contact the list administrators, e-mail: php-list-ad...@lists.php.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
Wasn't their an issue in using require/includes in classes, if's, whiles, or something? One would always be included where as the other would only be included if it meet the condition it was in. Sorry so vague.
-----Original Message----- From: Duke Normandin [mailto:01031...@3web.net] Sent: Tuesday, November 14, 2000 3:21 AM To: Lars Torben Wilson
Cc: php-gene...@lists.php.net Subject: RE: [PHP] Require() vs Include()
On 14 Nov 00 at 11:32, php-general-digest-help@lists wrote:
>Maxim Maletsky writes: >> OK, then.
>> what is the reason require() exists?
>> If it works the exactly same way as include() except that include can be >> more flexible why would we use require() then?
>> Any performance issues? >> usability? >> security?
>> Thanks Lawrence,
>In PHP 3, it was quite a bit faster than include(). There were other >semantic differences between the two as well, such as return values >etc. Performance appears to now be pretty much the same; you can >return values with include() now, and so forth and so on.
>BTW, require() will fail in a completely different way from include() >when it can't find the target file. include() will simply return a >false value, whereas require() will spit out a great big 'Fatal error' >and halt script execution.
Is my paraphrasing correct?
require() is "absolute" -- so don't use it in a conditional statement because it makes no sense (to me anyway)
require() is "absolute" -- make sure that what you "require" exists where it's suppose to be, otherwise the script fails "hard".
include() is *not* absolute -- use it in a conditional
include() failures do so "softly" - returns garbage, e.g.
Up to php4.0.1 require() had the edge on speed -- none to very litle with php4.0.2+.
-duke Calgary,Alberta, Canada
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
>> If it works the exactly same way as include() except that include can be >> more flexible why would we use require() then?
>> Any performance issues? >> usability? >> security?
>> Thanks Lawrence,
>In PHP 3, it was quite a bit faster than include(). There were other >semantic differences between the two as well, such as return values >etc. Performance appears to now be pretty much the same; you can >return values with include() now, and so forth and so on.
>BTW, require() will fail in a completely different way from include() >when it can't find the target file. include() will simply return a >false value, whereas require() will spit out a great big 'Fatal error' >and halt script execution.
Is my paraphrasing correct?
require() is "absolute" -- so don't use it in a conditional statement because it makes no sense (to me anyway)
require() is "absolute" -- make sure that what you "require" exists where it's suppose to be, otherwise the script fails "hard".
include() is *not* absolute -- use it in a conditional
include() failures do so "softly" - returns garbage, e.g.
Up to php4.0.1 require() had the edge on speed -- none to very litle with php4.0.2+.
-duke Calgary,Alberta, Canada
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
> Require will always add in the file even if its not executed.
> Eg
> if (isset($includeme)) { > require ("xxx.php"); > }
> require will be included in the file parsed by php
> but the following will not get included in the file if > $includeme is not > set.
> if (isset($includeme)) { > include ("xxx.php"); > }
> An important note about how this works is that when a file is > include()ed or > require()ed, parsing drops out of PHP mode and into HTML mode at the > beginning of the target file, and resumes PHP mode again at > the end. For > this reason, any code inside the target file which should be > executed as PHP > code must be enclosed within valid PHP start and end tags.
> Unlike include(), require() will always read in the target > file, even if the > line it's on never executes. If you want to conditionally > include a file, > use include(). The conditional statement won't affect the require(). > However, if the line on which the require() occurs is not > executed, neither > will any of the code in the target file be executed.
> The manual is actually pretty good on this topic imho.
> -----Original Message----- > From: Maxim Maletsky [mailto:maxim.malet...@japaninc.net] > Sent: November 14, 2000 12:34 PM > To: 'Lawrence.Sh...@dfait-maeci.gc.ca' > Cc: 'PHP General List. (E-mail)' > Subject: RE: [PHP] Require() vs Include()
> Well, > with include() if an included file does not exists it WILL fail.
> so where's the difference?
> -----Original Message----- > From: Lawrence.Sh...@dfait-maeci.gc.ca > [mailto:Lawrence.Sh...@dfait-maeci.gc.ca] > Sent: Tuesday, November 14, 2000 1:26 PM > To: Maxim Maletsky > Subject: RE: [PHP] Require() vs Include()
> include won't fail out if the includes not there, but require will.
> If you have something that *has* to be in there, then require > is used, if > something could be optional - eg a generated header or > something than might > be or might not be there at a given time, use include.
> -----Original Message----- > From: Maxim Maletsky [mailto:maxim.malet...@japaninc.net] > Sent: November 14, 2000 12:21 PM > To: 'PHP General List. (E-mail)' > Subject: [PHP] Require() vs Include()
> Hi, > A tiny question:
> why to use require() when include() works just as well and > even better when > there are some conditions like if{} ?
> I ask it because although I read many articles on this issue > I found no > reason for myself to use require() instead of include() and I > have driven > some huge projects in PHP.
> Why do I see these hardcore PHP gurus writing PHPLIB, mySQLadmin and > examples in their articles using require() where include() > would fit just as > perfect?
> WHERE THE TRIIIICK?
> It escapes from me ...
> Thanks.
> Maxim Maletsky - ma...@j-door.com <mailto:ma...@j-door.com> > Webmaster, J-Door.com / J@pan Inc. > LINC Media, Inc. > TEL: 03-3499-2175 x 1271 > FAX: 03-3499-3109
> -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net > For additional commands, e-mail: php-general-h...@lists.php.net > To contact the list administrators, e-mail: > php-list-ad...@lists.php.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
Now (since the PHP4.0.2) require() and include() are working in the EXACTLY same way. the only difference remains the premature exit of the file on a failure of require().
It is what Zeev wrote in his previous email on my thread.
-----Original Message----- From: Myke Hines [mailto:My...@WebSite.WS] Sent: Wednesday, November 15, 2000 3:39 AM To: php-gene...@lists.php.net Subject: RE: [PHP] Require() vs Include()
Wasn't their an issue in using require/includes in classes, if's, whiles, or something? One would always be included where as the other would only be included if it meet the condition it was in. Sorry so vague.
-----Original Message----- From: Duke Normandin [mailto:01031...@3web.net] Sent: Tuesday, November 14, 2000 3:21 AM To: Lars Torben Wilson Cc: php-gene...@lists.php.net Subject: RE: [PHP] Require() vs Include()
On 14 Nov 00 at 11:32, php-general-digest-help@lists wrote:
>Maxim Maletsky writes: >> OK, then.
>> what is the reason require() exists?
>> If it works the exactly same way as include() except that include can be >> more flexible why would we use require() then?
>> Any performance issues? >> usability? >> security?
>> Thanks Lawrence,
>In PHP 3, it was quite a bit faster than include(). There were other >semantic differences between the two as well, such as return values >etc. Performance appears to now be pretty much the same; you can >return values with include() now, and so forth and so on.
>BTW, require() will fail in a completely different way from include() >when it can't find the target file. include() will simply return a >false value, whereas require() will spit out a great big 'Fatal error' >and halt script execution.
Is my paraphrasing correct?
require() is "absolute" -- so don't use it in a conditional statement because it makes no sense (to me anyway)
require() is "absolute" -- make sure that what you "require" exists where it's suppose to be, otherwise the script fails "hard".
include() is *not* absolute -- use it in a conditional
include() failures do so "softly" - returns garbage, e.g.
Up to php4.0.1 require() had the edge on speed -- none to very litle with php4.0.2+.
-duke Calgary,Alberta, Canada
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscr...@lists.php.net For additional commands, e-mail: php-general-h...@lists.php.net To contact the list administrators, e-mail: php-list-ad...@lists.php.net