Re: include_once/__autoload/namespace emulation ...



On Tue, 29 Nov 2005 15:33:06 GMT, Kevin Newman <CaptainN@xxxxxxxxxxx>
wrote:

>I thought of that, but doesn't it try to load "XML_Parser" from within
>the class file, instead of just "Parser"? In some cases that would lead
>to to huge class names (and a lot of typing).

Huge class names really isn't an issue. You just don't 'new' objects
very often. Unlike in C# or Java, you don't have to declare the types
of variables so you just don't end up using full class names very
often at all.

I have a PHP5 project with 446 classes, arranged in the hierarchy
(XML_Parser is in XML/Parser.php) and I use __autoload.

>Also, I've read that there is a performance problem with __autoload -
>has that been taken care of?

I never experienced any performance issues with __autoload. In fact,
a quick googling for "__autoload performance" leads to a number of
posts/articles saying how it has improved performance of applications.

This makes sense, as __autoload only loads classes on demand. With
require/include you're loading classes whether or not you are actually
using them.

>I really wish the php guys would just implement at least class level
>namespaces (they already have a patch).

I honestly think you're over-thinking this. In reality, namespaces
are simply not the issue in PHP as they are for other languages. I
just use nice long class names.

.



Relevant Pages

  • Re: Will php ever do strong typing?
    ... > Will php 6 do strong typing and/or namespaces? ... > argue that weak typing is somehow better. ... Prev by Date: ...
    (comp.lang.php)
  • Re: PHP6 - Comments?
    ... >> For version 6, namespaces are becoming a topic again, since the sheer ... >> number of PHP projects will surely lead to name collisions. ... namespace collision is not a problem PHP ... > programmers' tendency to write rubbish documentation. ...
    (comp.lang.php)
  • Re: [PHP] Re: autoload with namespace
    ... methods and functions in the same code base that would use namespaces?" ... probably not being able to use namespaces in most places. ... I basically define one autoload method that consults ... which an individual may exclusively possess as long as he keeps it to ...
    (php.general)
  • Re: PHP6 - Comments?
    ... > For version 6, namespaces are becoming a topic again, since the sheer ... > number of PHP projects will surely lead to name collisions. ... required for that request, so how many times would you want to link to TWO ... Multiple inheritance does not exist in Java, so why should it exist in PHP? ...
    (comp.lang.php)
  • Re: [PHP] circular dependency between libraries
    ... problems and leave you with only the 'slightly' inelegant situation where you ... have to, internally, sync the 2 codebases now and again. ... If PHP had namespaces, I'd be happy. ...
    (php.general)