Difference between require, require_once, include and include_once



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.


Comments 0

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Difference between require, require_once, include and include_once

log in

reset password

Back to
log in