What’s the difference between include and require in php? - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-10-2011, 06:40 AM   #1 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 1
Thumbs up What’s the difference between include and require in php?

hi
What’s the difference between include and require in PHP?

Thanks
smith
smith41 is offline   Reply With Quote
Sponsored Links
Old 09-04-2011, 12:19 AM   #2 (permalink)
Junior Member
 
Join Date: Sep 2011
Location: Long Islanf, NY, USA
Posts: 33
Default Re: What’s the difference between include and require in php?

If include fails the script continues. If require fails the script ends.
Rukbat is offline   Reply With Quote
Old 09-05-2011, 10:38 PM   #3 (permalink)
Junior Member
 
Join Date: Sep 2011
Posts: 23
Default Re: What’s the difference between include and require in php?

To add to Rukbat's correct explanation you can also use include_once and require_once which will result in the script only being included if it hasn't already been included.
hoodle is offline   Reply With Quote
Old 09-19-2011, 07:25 AM   #4 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 4
Default Re: What’s the difference between include and require in php?

The main difference between include() and require() is Error handling.

The include() function always generates warning means it's does not halt the execution whereas require() function generates fatal error means it's stop execution immediately.
charlesth is offline   Reply With Quote
Old 10-24-2011, 04:31 AM   #5 (permalink)
Regular User
 
Join Date: Aug 2011
Posts: 26
Default Re: What’s the difference between include and require in php?

include will not fail if it cannot find the resource, require will. Honestly, it's kind of silly that include exists at all, because if you are attempting to load a resource you are pretty much counting on it being there. If you are going to use anything, I would recommend using require_once always, that way you don't run into collisions (ie, if another script is requiring the same file) and your code always works as intended because you know the resources you are including are there (otherwise it is failing).

mobile application developers
indiansareedesigns is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:56 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting