Difference between require, require_once, include and include_once

By Published On: April 17, 2011

All these functions require, require_once, include and include_once are used to include the files in the php page but there is slight difference between these functions. Difference between require and include is that if the file you want to include is not found then include function give you warning and executes the remaining code in of php page where you write the include function. While require gives you [...]


All these functions require, require_once, include and include_once are used to include the files in the php page but there is slight difference between these functions.

Difference between require, require_once, include, include_once

Difference between require, require_once, include, include_once

Difference between require and include is that if the file you want to include is not found then include function give you warning and executes the remaining code in of php page where you write the include function. While require gives you fatal error if the file you want to include is not found and the remaining code of the php page will not execute.

If you have many functions in the php page then you may use require_once or include_once. There functions only includes the file only once in the php page. If you use include or require then may be you accidentally add two times include file so it is good to use require_once or include_once which will include your file only once in php page. Difference between require_once and include_once is same as the difference between require and include.


Share this article

Written by : Junaid Rehman

I am a blogger and freelance web developer by profession. I love to blog and learn new things about programming and IT World.

Follow us

A quick overview of the topics covered in this article.

Join our website

Our partner website gives you a good reading experience

Latest articles