No problem. I am glad you found it useful. It sounds like if you're already using a consistent naming convention and using one class per file, then autoload should be usable pretty easily. It's really nice to get rid of a huge load of require and include at the top of every file.
For upgrading from PHP 4 to PHP 5 (I'd recommend 5.2), there are a few things to be aware of: http://www.php.net/README_UPGRADE_51.php Most of the issues may occur if you're doing stuff with functions return or using variables by reference. Beyond that, I'd make sure the classes were changed to have access modifiers (public, protected, private) and take advantage of the magic functions like __get(), __set(), __unset(), and __isset(). I'll write about those functions later. For mysql, the mysql and mysqli functions are available, but they may need to be explicitly enabled in the INI. However, with PHP 5 (and even with 4), I'd recommend moving away from using the database (any database) strictly with the mysql_* or mssql_* or oci_* or any other database specific functions, and move to using a database abstraction layer, such as PDO (also to be talked about later). PDO will let you use the same methods to talk to all sorts of different databases, and it's included in PHP 5.1 and later. I think you can also load it from PECL for PHP 4. Much of the code written for PHP 4 should work in PHP 5 with little or no effort, but it is important to test your apps before launching them into a production environment. At some point you may find that it's worth it to rewrite the app to take advantage of PHP 5 and OOP. Here's some of the topics I'd like to cover in future posts. I'd like to know if there's other stuff you'd like me to cover or if any of the listed topics sound more interesting and you'd like me to cover them first: - OOP in PHP 5 - __get() - __set() - __unset() - __isset() - Writing Unit tests with PHPUnit / SimpleTest - Acceptance testing with Selenium - Controlling the browser with PHP and Selenium - PHPDocumentor - particular PEAR packages - particular PECL packages - Patterns in PHP 5 - other topics... Thanks again, David On 12/1/06, Jim Mullen <[EMAIL PROTECTED]> wrote: > > David, > > Thanks for the write up on __autoload! I didn't know that function > existed. I create PHP 4 classes in separate files and use a standard > naming convention of class.[class name].php . So, that might work well > for me. > > I'm still using PHP 4.3.10 but am interested in moving to 5(.2?). The > one big thing that's stopping me is not knowing what will break when I > move from 4 to 5. I have a bunch of sites hosted using PHP 4 but if I > upgrade to PHP 5, I'm afraid I'll break everyone's site. For example, I > know mysqli is used in PHP 5 but have worked on a site with PHP 5 where > the "normal" mysql functions were still available. How'd they do that? > That would make switching to 5 easier. > > I have been doing OOP PHP professionally / on the side for a while. > I've created a decent sized CMS (content management system) from scratch > for an online newspaper and have also developed a mailing list > management app. > > So, I would be interested in seeing a list of things that have changed > between 4 and 5 (like using mysqli instead of mysql and which version of > mysql server is required to use mysqli, list of new functions, etc) and > how to upgrade PHP apps from 4 to 5. > > Best regards, > Jim > -- > http://www.iDimensionz.com Professional web site design and affordable > web site hosting. > ---------------------------------------------------------- > Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=38044&t=84> > -- Get the new open source web browser, FireFox, and enjoy features like > pop up blocking, tabbed browsing and MUCH more! > Get Thunderbird! > <http://www.spreadfirefox.com/?q=affiliates&id=38044&t=178> -- Get the > new open source e-mail client, ThunderBird, and enjoy features like > integrated spam filter, privacy protection, integrated RSS reader and > MUCH more! > > [Non-text portions of this message have been removed] > > > [Non-text portions of this message have been removed]
