[nycphp-talk] Include vs Include_once
Daniel Convissor
danielc at analysisandsolutions.com
Sat Dec 1 08:54:34 EST 2007
Hi John:
On Fri, Nov 30, 2007 at 08:51:57PM -0800, John Zabroski wrote:
>
> How do you address the fact __autoload magic method is
> part of the global namespace and that when two blocks
> of code with the same signature are loaded on demand,
> the function closest to the top of the stack is
> selected?
What do you mean by "the function closest to the top of the stack is
selected?" You can only have one __autoload() function in your code
base otherwise you'll get a fatal error. Also __autoload() does whatever
you program it to do.
> Do you even use __autoload directly? If so, do you
> think your comments above contradict using __autoload
> as a best practice for structuring code?
No, autoload is not meant to be called directly. I didn't say using
autoload is a best practice, though that doesn't mean that it isn't a
good/best practice.
> Do you use spl_autoload_register, and if so, how?
I have not. I just manually declare it the "normal" way in my
functions.inc file:
function __autoload($class) {}
> In my humble opinion, it is these questions that truly
> complicate inclusion semantics in PHP.
I think you're over-complicating things.
> However, such a suggestion
> ignores the fact maintenance programming can create
> *gaps* and *overlaps* in logic that cause two
> functions to exist in the same namespace,
Then you haven't written good code. For example, you can "namespace"
your functions and classes by prefixing or postfixing them with something
unique, like the initials of your company.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list