Re: [PHP] optimal code

2001-07-05 Thread Thies C. Arntzen
On Thu, Jul 05, 2001 at 02:29:12PM +0300, 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) {

Re: [PHP] optimal code

2001-07-05 Thread Justin Farnsworth
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

RE: [PHP] optimal code

2001-07-05 Thread Richard Heyes
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... Not in my experience. I have a file which defines ~40 functions, with the bodies included when the function is

RE: [PHP] optimal code

2001-07-05 Thread Nick Davies
surely the include function only pastes the contents of the included file into the point where the include statement occours. Php still has to parse it all. On Thu, 5 Jul 2001, Richard Heyes wrote: If you are talking about speed, opening a file is expensive because it is a kernel call, a

Re: [PHP] optimal code

2001-07-05 Thread Justin Farnsworth
But, my friend, if you include that file, PHP _still_ has to parse it. You just didn't benchmark. No matter what ?php big_code_inline; (which PHP has to interpret) ? will beat ?php include file_with_big_code_inline (which PHP has to interpret) ? because of

Re: [PHP] optimal code

2001-07-05 Thread Justin Farnsworth
Nick Davies wrote: surely the include function only pastes the contents of the included file into the point where the include statement occours. Php still has to parse it all. --- Right, and so no matter what, you still have the extra cost of the file operation, something almost a magnitude

RE: [PHP] optimal code

2001-07-05 Thread Richard Heyes
But, my friend, if you include that file, PHP _still_ has to parse it. You just didn't benchmark. No matter what Actually, I did do benchmarks, you simply didn't understand correctly. Not all of the functions are used on every page. So if I were to include all the functions in one file,

Re: [PHP] optimal code

2001-07-05 Thread teo
Hi Richard! On Thu, 05 Jul 2001, Richard Heyes wrote: 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... Not in my experience. I have a file which defines ~40

RE: [PHP] optimal code

2001-07-05 Thread Richard Heyes
Having all the function bodies in the same file would cause php to have to parse all of that code, probably about 3-4000 lines causing awful slowdowns. And the reason to define all of the functions in one file, is so that we can include that file, and all the functions are then