Jump to content

require vs require_once


terryds

Recommended Posts

Both do same it pulls the file (something like interpreter handled copy paste) and if file extension supports to parse or execute it will parse it eg when you use require_*() to php file. The only difference between both is. require_once() maintain a hash table which consists of list of file it is already included. Where as require() does not have that and try to include same file as many times it encounters. As require_once() check its hash table before any inclusion of files it is little slower (academically) than require(). though it is negligible.Usually you would use require_once() where you must have to include a file for one time, like class,function declaration Where as you can use require() in repetitive scenario.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...