PHP – require_once statement

The require_once statement is almost similar to require statement except PHP will check if the file has already been included in the program or not, and if the file already included in the program then it will not include again in the program.

The require_once statement in PHP

So if you want to be sure that the should be included only once then you should only use the require_once statement to include any file in the program.

You can understand the require_once statement using the following example:

The require_once statement in PHP will ensure that the file must be included only once and if in case, the file doesn’t exists it will generate the fatal error and program execution will stop working immediately.

Leave a Reply

Your email address will not be published.