Personally, I use objects in 'boring' websites for the entire page. I have a page object which is instantiated at the beginning on the script and starts up the output buffer. From there, I can set the title any number of times throughout the script, add external stylesheets, external javascript or change the format overall. Then, when the script is done, the __destruct magic method turns off the output buffer, takes the contents of the buffer and throws it into the content section of my XHTML. Then it outputs the entirety to the browser.
The advantages of all of this is that I make one include at the top of my page (which automagically creates a $page object and starts up the buffer) and from then on out, I know that all of the output from my script will be properly placed in the XHTML and be consistent with the rest of my site. Also, I can start out the script with one title "Please fill out this form" and, depending on where things go in the script, I can have to change to "You made a mistake on the form" or "Thank you for filling out the form" all with a simple $page->setTitle(); And I never have to worry about planning ahead to set titles, or include stylesheets, javascript, keywords, descriptions, since I can add or change these things right up until the very end of the script without a problem. Aside from that, I use a database object to manage my connection and queries (it's nice to have helper functions in that object) and I also find myself using them a lot for repetitive tasks (though I guess these could be relegated to functions). Overall, just about anything you can do with an object can be done with a bunch of functions and variables, but objects just make it easier. If a group of functions and variables are all used for the same thing, shouldn't they be grouped together anyway? Sorry for the extended commentary, I just love objects. On 7/17/07, Brian O'Connor <[EMAIL PROTECTED]> wrote:
My apologies, the web browser decided to send prematurely on that one. Hello all, I've been on this list for a few years now reading, and attribute much of my knowledge of PHP to users on this list (in one way or another). I am currently rebuilding my homepage from scratch, which means I have to redo all the server side code. Now, traditionally I've built all my web sites using php4, but I've looked a lot into php5 and its new OOP support. As a little background, I'm currently a computer science student in college, and have studied oop to a great deal. Here's my problem : I don't see how using php5 and oop would really benefit me in building websites. I understand objects, code reusability and all that. So I'm going to put the areas of my site here, and see how you guys would build objects for them. I have these sections: News Portfolio Code (samples of code that I've written, for resume-type purposes) Tutorials Contact About Me At first glance, I thought to object-ify the portfolio section, where each "project" would be an object. But other than that, I don't see anywhere on the site to use objects, and I could easily do that without objects. I'd like to expand my resume by being able to say that I have done OOP in php5, as I see on the jobs list that that is what employers are looking for (at least quite a few are). In addition, I was wondering what your suggestions are for php5 and oop, I don't need an oop introduction or anything like that, I'd just like some examples of how using objects would make the site better and how to structure them. Thanks in advance, -- Brian O'Connor _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
_______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php