Re: optimal code

From: Date: Thu, 05 Jul 2001 11:51:28 +0000
Subject: Re: optimal code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56296@lists.php.net to get a copy of this message
This depends upon what you mean by "effective". For administration purposes, it may be that you want to include some "commen" code, and therefore not rewrite reusable bits. If you are talking about speed, opening a file is expensive because it is a kernel call, a directory search and all that. Your "some big code" in-line will beat it every time... If you require, and the thingy has been already loaded, then you will have to analyze how many times you use it, and try to determine tradeoffs. This is difficult. My take is, unless you are getting 100,000 hits a day and your server load is 0.99, do what is best for reusability, clarity, and administration purposes. _jef -------------------------------------- Adrian Ciutureanu wrote: > > Is any of the versions below more effective? > > /** Version 1 **/ > <? > if($condition) { > // some big code > } else { > // other big code > } > ?> > > /** Version 2 **/ > <? > if($condition) { > include 'file_with_some _big_code.php'; > } else { > include 'file_with_other_big_code.php'; > } > ?> > > /** Version 3 **/ > <? > if($condition) { > require 'file_with_some _big_code.php'; > } else { > require 'file_with_other_big_code.php'; > } > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722

« previous php.general (#56296) next »