What is the difference

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Forum Newbie
Posts: 1
Joined: Wed Jun 03, 2020 4:45 am

What is the difference

Post by rihitobach »

Hi there, just a question that looks for your ideas. What is the difference between include_once() and require_once(), which one would you use in circumstances where you need to connect to a database, and why?
User avatar
Site Administrator
Posts: 6911
Joined: Sun May 19, 2002 10:24 pm

Re: What is the difference

Post by Benjamin »

This sounds like a test question. Historically we don't answer questions like that. Sorry!
Forum Newbie
Posts: 3
Joined: Tue Apr 13, 2021 4:46 am

Re: What is the difference

Post by richnieh »

There are some really thorough explanation about these functions/statements online. For example, https://stackoverflow.com/questions/241 ... clude-once.

Personally, I think most of the applications nowadays are using autoloaders which has require_once in most of them I think (funny that the example in PHP manual about autoloading class is using include). If you are interested, you can do some reading about autoloaders articles might be useful for you.
Post Reply