Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Difference b/w include() and require()

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Difference b/w include() and require()

Postby ishwardgret » Tue Feb 12, 2013 10:48 am

What is difference between include() and require()? What is good practice with specific case?
ishwardgret
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Nov 18, 2012 1:20 am

Re: Difference b/w include() and require()

Postby seandisanti » Thu Feb 14, 2013 2:03 pm

both allow you to internalize code from other files into the calling one, but require() is a strict include in that execution will stop if the other file is not found or readable. using include() may help avoid a fatal error at the time of include, but as soon as you go to use a function or object from a file which is not actually included, you'll end up running into another fatal error that may be tougher to spot the cause of. Personally I use require, and an __autoload() function to load class files as necessary instead of requiring everything up front.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 783
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.