I discovered a few months ago, while I was converting one of my sites to be database driven that PHP has objects. This was news to me. (Okay, not entirely. I’ve been using the DOMDocument object for years. But the extensiveness of the object library, and the ability to create and extend classes was new.) I’ve always thought of PHP as fairly procedural language. But being able to extend the mysqli objects has been really useful. Also the discovery of the function_exists and class_exists functions was really nice.
if(!class_exists('readDB')
include 'readDB.php';
is one of the greatest pieces of code that exists. [Edit: I've since learned about include_once which solves this problem in one line...] Not having to worry about accidentally including a file twice, or not at all is particularly wonderful.
Also, I’m a fan of exceptions.
On the aforementioned rowing team site, it occurred to me yesterday that I could probably create an Ad container object, and then extend the DOMDocument object specifically to process the Ad editing form (I did convert them over to XML), and even output the required HTML. But I haven’t sat down to do it yet. It’s too hot in my un-air-conditioned house to think about it. But it’s supposed to be cooler Thursday, so I’ll probably write about how that’s going Friday.
No comments:
Post a Comment