Difference between include, require, include_once and require_once in PHP

Posted on

First of all we should know what is the difference and similarity between include() and require(), include() and require() are used to include other files into a PHP file, and the difference between them are the include() generates a warning when there is an error, but the script will continue execution, otherwise, the require() generates a fatal error, and the script will stop.

The require_once() statement is similar to require() except require_once() will check if the file has already been included, and if so, it will not require it again, same with include_once().

Leave a Reply

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