Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,983 members, 7,806,870 topics. Date: Wednesday, 24 April 2024 at 05:36 AM

What's The Difference Between "require Once" And "include" In Php? - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / What's The Difference Between "require Once" And "include" In Php? (6821 Views)

7 Reasons Why You Must Include Images In Blog Posts By Mediapace / What’s The Difference Between A Mobile Website And Responsive Web Design? / What Is The Difference Between A Web Designer And A Web Developer? (2) (3) (4)

(1) (Reply) (Go Down)

What's The Difference Between "require Once" And "include" In Php? by cmon(m): 12:39pm On Sep 18, 2007
Please I'ld like solutions to the above topic
Re: What's The Difference Between "require Once" And "include" In Php? by my2cents(m): 2:00pm On Sep 18, 2007
Re: What's The Difference Between "require Once" And "include" In Php? by kazey(m): 2:18pm On Sep 18, 2007
Dont get confuse with the _once attribute. The function is basically include() and require(). the _once attribute can be added to both.

And Both actually do the same thing in regards to adding the specified file, but are different in the way they handle failures. _once is included in the respective functions to avoid problem with function redefinitions. That is preventing the file been included for evaluation or execution from been added more than once.

The difference between include() and require is simply, when the specified file is called in both cases , and the file does not exist for example, the require() function returns a fatal error while the include() function, returns a warning, which means the scripts calling the function does not halt, as in the case of with the require().

so its basically, the include() function in a script would show a warning if the specified file does not exist and the require(), function would return an error and halt if the file been called for evaluation or execution does not exist for example.

The require makes the file inclusion compulsory , while the include can continue with the other part of the calling script if applicable, if that specified file in the function does not exist.

Looking for a host for your PHP Websites try Nairahost at Nairahost Nigeria
Re: What's The Difference Between "require Once" And "include" In Php? by cmon(m): 11:17pm On Sep 22, 2007
Thanks for your contributions.

@kazey,
Thanks particularly.
You don't need to tell me about Nairahost cos I already have a couple of sites hosted with you guys. Keep up the good work. You've been impressive. So far.

(1) (Reply)

The Best Nigerian University Website / Can I Start A Car Blog In Nigeria? / The Benefits Of Promoting Your Business Through Bulk SMS

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.