include , require and require_once , include_once in php
include, require and require_once,include_once are used to include a file into the PHP code
forexample of include and require
<h1>Welcome to My blog!</h1>
<?php include 'header.php'; ?>
itcan addedfile in php code.
in require example
<h1>Welcome to My blog!</h1> <?phprequire'header.php'; ?>
difference between include and require
file is included with the include statement and PHP cannot find it, the script
will continue to execute
echo statement will not be executed because the script execution dies after the
require statement returned a fatal error
It can be used include a PHP file another one, it can used to add files once. If it is found that the file has already been included, calling script is going to
ignore further inclusions.
include_once('name of the called file with path'); example <?php include_once('xyz.php'); ?> same as require_once used. <?phprequire_once('example.php') ?> include_once and require_once same different with include and require.