PHP – include statement

The include statement in PHP is also used to include any external file in the program. But if we use include statement then it will generate just a warning and execute the program and will display the results as per the input value.

The include statement in PHP

You can understand the include statement using the following example:

Difference between include and require statement in PHP

The function of both the statements are almost similar except in case of require statement, if file doesn’t exists then it will generate a fatal error and it will stop the program execution immediately but in case of require statement, it will just check the file and if it doesn’t exists then it will just display a warning and execute the program.

So if we want to be a file is included in the program then we should use the require statement only.

Now I hope you are all clear about the include and require statements.

In next chapter, we will see how to use require_once and include_once.

Leave a Reply

Your email address will not be published.