Re: How PHP handles multiple inclusions of the same file?

From: Date: Tue, 10 Aug 2004 00:04:50 +0000
Subject: Re: How PHP handles multiple inclusions of the same file?
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-193235@lists.php.net to get a copy of this message
Much better to use a *function* which is parsed once then include()ing or eval()ing the same code over and over to (possibly) be
re-parsed.
//I read file once: $handle = fopen($fileName, "r"); $script = 'function use_cached_code(){ ?>'; $script. = fread($handle, filesize($fileName)); $script. = '<?php }'; //parse it once: eval($script); //and use the code as much as I want: use_cached_code();
It just makes more sense code structure-wise as well.
Not in my case, believe me. Otherwise I would not ask about caching.

« previous php.general (#193235) next »