Skip to main content

What is the difference between include and require?

Entry PHP
Quick Answer include: shows warning if file not found, script continues. require: shows fatal error if file not found, script stops. Use require for files that are essential (DB config, core functions) - the app can't run without them. Use include for optional files. Both have _once variants that prevent re-including the same file: require_once and include_once.

Answer

include gives a warning on failure; require stops execution with a fatal error.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice