NYCPHP Meetup

NYPHP.org

[nycphp-talk] to __autoload or not to __autoload?

David Mintz dmintz at davidmintz.org
Mon Sep 5 15:29:43 EDT 2005


If you use HTML_QuickForm with a PHP5 __autoload() function such as the
following...

function __autoload($class) {
	include_once(str_replace('_',DIRECTORY_SEPARATOR,$class).'.php');
}

...you can get burned by a line in RuleRegistry.php that depends on PHP4
classname insensitivity where it tests whether something
is_a('lowercase_classname')

   if (is_a($element, 'html_quickform_group')) { /* ... */ }

And it seems that there has been some controversy over whether this is a
bug requiring fixing, or the user's problem
(http://marc.theaimsgroup.com/?l=pear-dev&m=112241111400053&w=2 etc).

In my case it won't be a problem if I either fix this line myself, or stop
using __autoload().

But an __autoload() is also going to fail where classes are bundled in the
same file, which in some cases is not an unreasonable thing to do, imho.

So I am wondering what people's thoughts are about __autoload() generally.
Do you?  Why or why not?



---
David Mintz
http://davidmintz.org/



More information about the talk mailing list