Ibrahim Azhar Armar Ibrahim Azhar Armar - 1 year ago 98
PHP Question

include, include_once, require or require_once?

I have PHP file where I have defined the server access variables as well as the

, as this functions are regularly used in almost every page in backend, while I am using
which is perfectly working for me now, which method or function would you suggest and I would like to know if there is any flaw if I use
or is it safe to use it?

Edit : Keeping in mind I'll be using
variable too.

Answer Source

The only difference between the two is that require and its sister require_once throw a fatal error if the file is not found, whereas include and include_once only show a warning and continue to load the rest of the page. If you don't want PHP to attempt to load the rest of your page without the database info (which I would assume), then use require_once. You don't need to include the file more than once, so there is no need to use the regular require function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download