Re: Procedural Autoloader?

From: Date: Mon, 22 Nov 2010 23:05:04 +0000
Subject: Re: Procedural Autoloader?
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-309633@lists.php.net to get a copy of this message
On 22 November 2010 22:02, David Harkness <david.h@highgearmedia.com> wrote: > The simplest solution would be to move those functions into static methods > of classes. Place one class in each file to organize your functions and use > an autoloader to load the classes. You don't need to instantiate the class > to use the autoloader--just reference it statically: > >    // library/Math.php >    class Math { >        const PI = 3.14159; > >        public static function sin($radians) {...} >    } > >    ... > >    $x = $radius * Math::cos(Math::PI * 0.5); > > David > Would it be overboard to use a namespace? Aren't namespaces handled by the autoloader? If not autoload(), how about spl_autoloading? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

« previous php.general (#309633) next »