What is the difference between include and require?

“include” means the file is being included in the current script and can be accessed any number of times in the script.

If the file being included is not found, then the script will throw an error, and will continue running further. It will not stop.PHP Questions

“include_once” is used to tell the script that the mentioned file is to be used or accessed only once during the script execution.

In the case of “require”, if the mentioned file is not found then it will give a fatal error, and the script will not execute further.

“require_once” is used to tell the script that the mentioned file is required only once during the program execution.

Leave a Reply

Your email address will not be published. Required fields are marked *