PHP include Statement

PHP include Statement

The PHP include statement also include a file into your PHP code, but it has a benefit over PHP require statement. While executing include() statement, if the file isn’t found, then the script won’t stop. It will continue, unlike require statement, which returns an error, if the file isn’t available.

Here’s the syntax,

Now, we will learn with an example. We have two files, credits.php and index.php.

Here’s the code for index.php, wherein we’ve included credits.php file using the include 

Here’s the code for credits.php. We’re adding a single line here for site credits.

Here’s the output, which shows the site credits,

PHP include statement

PHP require Statement
PHP Online Quiz 1
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create free tutorials for all.

No Comments

Post A Comment