What is difference between require_once() and require()??

by:

PhpPHP Interview Questions

The main and basic difference between them is …..

When we use require_once() to include the file as the name tells once. it means the file that is included is be used only at one time cannot be included another time.

Sometimes we have functions in the file. that’s why we suggest to use require_once so that we will not get re-declarations of functions.

In case of require, there may be error comes of redeclarion of same functions.

So recommended require_once to be used whenever we want to include a file.