Difference between require and include in php


Posted on 28 Dec 15 by Vickey

When we need to use content of a page in another page we use require or include statement.The require and include function do the same thing load one file code in another but there is a major difference between require and include.As the meaning of word require we can understand. We use require word where we need a thing on urgent bases means we can not complete our work without this.This is the same in php also if we load a file content with require statement and this file not found on the given path it will give fatal error and script will stop. But if we are using include it will give a warning and script will be continue

require('path of file'); //fatal error

include('path of file'); //   WARNING


If this post help you reduce time to develop, you can help me to maintain this website :)