The include_once statement in PHP is almost similar to include statement as we have already read about the include statement in previous chapter. But in case of include_once, it will ensure that the file is included only once in the program and in case, the file doesn’t exists then it will just generate a warning and execute the program just like the include statement.
You can understand this using the following example:
// HERE IS THE OUTPUT
Difference between include_once and require_once statements in PHP
Both the statements will ensure that the file is included only once in the program. But the main difference is that in case of require_once if file doesn’t exists then the program will generate a fatal error and it will stop the program execution immediately but in case of include_once, it will just display a warning message and execute the program.
Now I hope you are all clear about include, include_once and require, require_once.