Reputation: 9486
Is there any difference in overhead for using include_once vs. conditional include?
this:
include_once('logins.php');
vs this:
if( !in_array( 'logins.php',get_included_files() ) ) { include('logins.php'); }
Obviously include_once is a lot easier to type and possibly/probably performs the same operation behind the scenes as the conditional include performs. But I don't know for sure and I seem to remember reading that lots of "include_once"s add a lot of overhead to the code.
thanks
Upvotes: 2
Views: 194
Reputation: 490607
If you want to include a file once, use include_once
. Keeping your own registry is just more code to write, document, debug and unnecessary noise when include_once
works.
The only time I would recommend doing otherwise is if your application had performance issues, and measuring the issue showed the bottle neck was including files with include_once
. I can almost guarantee that won't be the case.
Upvotes: 3