which is faster: include() or all in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
calebsg
Forum Commoner
Posts: 28
Joined: Tue Jun 18, 2002 10:41 am

which is faster: include() or all in

Post 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?
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post 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.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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
calebsg
Forum Commoner
Posts: 28
Joined: Tue Jun 18, 2002 10:41 am

Post 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.
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

having a descriptive, organized naming system sounds clutch here, unless it's job security you're looking for...
kevinm
Forum Newbie
Posts: 1
Joined: Sat Jul 06, 2002 11:06 pm
Location: Toledo, OH

Post 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
Post Reply