Page 1 of 1

which is faster: include() or all in

Posted: Thu Jul 04, 2002 3:53 pm
by calebsg
I have a web page that starts with switch statement that has several cases and each case has one shared function (basically a design template) and it's own unique function. There's a lot of HTML in most of the case parts because I'm dealing with the addition, editing and viewing of a fairly large set of data.

My question: is it better to have all the functions with their html right in my php file (1400+ lines), or should I have an include() for the html pertaining to each function?

The latter would make my main php file shorter, but would it make it faster to process and output?

Posted: Thu Jul 04, 2002 11:01 pm
by llimllib
If there is a performance gain from not including the files, IMHO, it's a) negligible and b)worthwhile to make sure that if anyone ever wants to read your code, they can.

Posted: Fri Jul 05, 2002 12:36 am
by hob_goblin
I'd include them... just because it would be easier on me, and it's not really that much of a performance loss.. maybe a couple milleseconds

Posted: Fri Jul 05, 2002 8:17 am
by calebsg
Well I was thinking that including all them would be easier too, but that raises the question: how do you keep track of all your include files??? :)

Thanks for the input.

Posted: Fri Jul 05, 2002 8:53 am
by llimllib
having a descriptive, organized naming system sounds clutch here, unless it's job security you're looking for...

Posted: Sat Jul 06, 2002 11:06 pm
by kevinm
Seperating code (PHP) from presentation (HTML) really is vital, and something oft-overlooked. For more flexibility, you should include those files rather than sticking them in with your PHP.

If you want to go a step further, use templates (e.g. Smarty) for even greater flexibility.

-k