[nycphp-talk] Include vs Include_once
Daniel Convissor
danielc at analysisandsolutions.com
Fri Nov 30 23:11:43 EST 2007
Hi John:
On Fri, Nov 30, 2007 at 12:13:14AM -0500, John Campbell wrote:
>
> That is news to me. Why is include_once a performance drag?
As Rob mentioned, include_once makes the PHP perform stat calls on the
file system to make sure the file you want to include has not been done
already. Rasmus went over this at the NYPHP conference last year in a
talk entield "Getting Rich with PHP."
http://talks.php.net/show/nyphp06/8
PHP may have been optimized since then, but regardless of how optimized
it has gotten, the file system checks cost more than not having to do
them.
> What is
> the better programming logic, that doesn't just duplicate the
> behavior?
Take the time to strucutre the logic to only include a given file one
time. For example, including critical files up front. While clean logic
can't eliminate all uses of include_once, it can get rid of most.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list