|
Posted by Chris Hope on 05/11/05 10:31
chotiwallah wrote:
> suppose i have the following code:
>
> switch ($inc):
> case 0:
> require 'inc0.php';
> break;
> case 1:
> require 'inc1.php';
> break;
> case 2:
> require 'inc2.php';
> break;
> endswitch;
>
> question:
> does php actually include and parse all 3 files, or just the one
> needed (isuppose so, but i'm not sure)? how does that influence
> performance (each inc is about 40k)?
Only the one needed will be included in your script. Both include() and
require() work pretty much the same way except require() will produce a
fatal error if the file could not be included, whereas include() will
just show a warning on error.
I think the behaviour was changed from PHP4 on, as I'm pretty sure in
PHP3 require() included the file regardless of any conditional code.
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Navigation:
[Reply to this message]
|