Aug 8, 2012

Difference Between include, include_once, require, and require_once

Every time I worked on PHP, I always used include, then later on I wanted to know the difference between include, include_once, require, and require_once. After googling I came to know the difference.

  • include: Includes and evaluates the specified file, throwing a warning if the file can’t be found.
  • include_once: Same as include, but if the file has already been included it will not be included again.
  • require: Includes and evaluates the specified file (same as include), but instead of a warning, throws a fatal error if the file can’t be found.
  • require_once: Same as require, but if the file has already been included it will not be included again.

No comments:

Post a Comment