Sunday, 9 June 2013

What is the difference between include and require in php?


Example -

In php we can use include and require statements to insert the contents of one file into another.  This helps in modular approach to web development.
Difference between require and include is given below.
  • require will produce a fatal error (E_COMPILE_ERROR) and stop the script
  • include will only produce a warning (E_WARNING) and the script will continue

Code and Syntax

File – sample.php

<?php
require ‘abc.php’;
include ‘xyz.php’;
require_once ‘tt.php’;
?>


Explanation
In above program, we have included 3 files in sample.php.


For more php questions and answers, dumps, tutorials for beginners and experienced people visit http://www.top-php-interview-questions.blogspot.in  If you find any errors while executing this program, you can make your comments or mail me at reply2sagar@gmail.com













No comments:

Post a Comment