Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will require_once and include_once together include the file twice?

Tags:

include

php

If I have this:

require_once('myfile.php');

then later:

include_once('myfile.php');

Will the file get included again or just the once?

Also what is the difference between the two? Require causes an error on failure and include tries to recover? any other differences?

like image 213
JD Isaacks Avatar asked Sep 07 '10 14:09

JD Isaacks


1 Answers

If the file is included, it is included.

requice_once() works exactly like include_once(), except that it kills the script when the script to include is not found.

Therefore in your example, the script is included once.

like image 192
mauris Avatar answered Oct 09 '22 16:10

mauris