Re: require_once problem

From: Date: Wed, 09 Feb 2005 16:21:16 +0000
Subject: Re: require_once problem
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-36098@lists.php.net to get a copy of this message
Sebastian Bergmann wrote:
Or we could think about how to use __autoload() in PEAR.
Well I think it is indeed a good idea to talk about how we want to use __autoload() in PEAR for php5 only packages. To me this is the single coolest feature of PHP5. However its obviously not smart to require users to use our __autoload() implementation. However I do agree we should provide an implementation that will take a given class name and load the necessary class ... this is what I have in LiveUser ..
    function loadClass($classname)
    {
        if (!class_exists($classname)) {
            $filename = str_replace('_', '/', $classname).'.php';
            if (!LiveUser::fileExists($filename)) {
                return false;
            }
            include_once($filename);
            if (!class_exists($classname)) {
                return false;
            }
        }
        return true;
    }
if we put this into PEAR then users of the php5 only classes could use this implementation in their own __autoload() implementation. regards, Lukas

« previous php.pear.dev (#36098) next »