What is difference between include and require in php?

1 answer

Answer

1272166

2026-04-05 08:45

+ Follow

include will continue executing the script even with errors while require will produce a fatal error and stop the script.

Note: if you put include/require 'grandpa.php' in 'father.php' and then include 'father.php' in 'son.php' and also put include/require 'grandpa.php' in 'son.php' then both require & include will produce errors.

Best thing to add is include_once or require_once in your code as it will only add the file once and will override other include_once or require_once

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.