Differentiate between require() and include() function in PHP?

  • require() and include() function in PHP are used to include a file. But the type of error if the file not found is different.
  • include() function sends an error if file not found, whereas require() sends a fatal error.
  • The include statement includes and evaluates a specified line. That is it will include a file within a given path.
  • include will allow script to continue, whereas require will not allow script to continue.
  • require_once() function will check if the file has already included. If so it will not include the file specified in the path again.