Monday, 28 September 2015

include , require and require_once , include_once in php

 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

for example of include and require

<h1>Welcome to My blog!</h1>
<?php include 'header.php';

it can added file in php code.

in require example

<h1>Welcome to My blog!</h1>
<?php require 'header.php';

difference between  include and require

 when a file is included with the include statement and PHP cannot find it, the script will continue to execute


the 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');


<?php include_once('xyz.php'); 


same as require_once used.

<?php require_once('example.php')  ?>

include_once and require_once same different with include and require.

No comments:

Post a Comment

Thank You For Comment