PHP include Statement

The PHP include statement also includes a file in your PHP code, but it has a benefit over PHP require statement. While executing the include() statement, if the file isn’t found, then the script won’t stop. It will continue, unlike the 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 the 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 2
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading