Jump to content

require vs require_once


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...