2

the difference between require and require_once. I just want to know the difference rather than Warning and Fatal Error in php.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
Ravi Mane
  • 1,468
  • 2
  • 18
  • 24

1 Answers1

29

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).

So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

Source