Page 1 of 1
Class or just an include?
Posted: Sun Oct 17, 2004 2:47 am
by bobbyaa
What's your opinions on header/footer templates. Would it be more efficient to generate a class that has them and pass the variables like title, etc? Or is it more efficient/easier to just create the pages and include those pages?
Thanks,
Robert
Posted: Sun Oct 17, 2004 4:18 am
by patrikG
Depends on the scope of your application. If the header and footer would always be the same, have a static include.
If it needs to be done dynamically use a function.
If you need to filter HTTP request, or access the database or, more general, process the some data (as in modify data), use a class.
Posted: Sun Oct 17, 2004 8:28 am
by m3mn0n
I'd say a Class no matter, but that's cause I love OOP.

Posted: Sun Oct 17, 2004 8:53 am
by kettle_drum
Yeah i follow in Sami's footsteps - Always a class for anything larger than say just printing text to the screen. It makes you group all the related functions and have a completly self-contained unit that you can use on other projects.
Posted: Sun Oct 17, 2004 9:28 am
by John Cartwright
3 cheers for classes! HIP HIP HURRAY!
Posted: Mon Oct 18, 2004 2:51 am
by patrikG
I don't want to bring up that old function vs class discussion at all, but to blindly vote for OOP for something as simple as an include is somewhat one-eyed. It depends entirely on the scope and purpose of the application. Perhaps bobbyaa could shed some light on what he wants to do and what it's for.
Posted: Mon Oct 18, 2004 5:26 am
by Christopher
I agree with patrikG, if you have simple headers and footers just include them. If you need encapsulation, inheritance, etc. then use a class.