I'm creating classes that rely on the presence of other classes that I've
created.  Does PHP5 provide a way to specify these dependencies or a way to
check these dependencies when the class is instantiated?  For example, class
Automobile would fail to instantiate if class Tire wasn't available.

I know the __autoload feature of PHP5 could be used to flag an error like
this:

function __autoload($class_name) {
        if ([EMAIL PROTECTED]("$class_name.php")) {
                echo "Error:  Unable to load $class_name.<br>";
        }
}

This solution may work to some degree, but it doesn't tell me which class
depended on the missing class, which would be helpful in troubleshooting.
Also, it seems like you'd want to check dependencies first thing, rather
than getting part way through the application before having an error occur.

What do you think?  What approaches do you guys use on this?

Thanks,

Ed

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to