I download a framework and code and I have a question regarding require and include vs class_exists.
In the code I download, I see:
require_once('class.php');
As well as:
if(class_exists('class') == false) { require('class.php'); }
I get require_once means only 1 time and class exists check if the class exists.
My question is: is the second better than the first one? and why?
this condition:
prevent the
require_onceto be called.require_oncecan be slow if you have a lot of files you include in your project (specially frameworks) because they have to scan the code to make sure the file is not included twice or more. so if you have over 25 file you include and they are nested, require_once will have to check all of them.