require(), include() and include_once() Functions

Q

What are the differences between require(), include() and include_once() functions in PHP?

✍: FYIcenter

A

All three functions are used to include and evaluate a file into the current script execution.

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again.

The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.

2007-02-27, 5052👍, 0💬