Re: What's wrong the __autoload()?
| From: | Nathan Nobbe | Date: | Wed, 12 Mar 2008 19:48:29 +0000 |
| Subject: | Re: What's wrong the __autoload()? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271427@lists.php.net to get a copy of this message | ||
On Wed, Mar 12, 2008 at 3:35 PM, Zoltán Németh <znemeth@alterationx.hu>
wrote:
> 2008. 03. 12, szerda keltezéssel 15.20-kor Robert Cummings ezt írta:
> > Even JavaScript has it.
>
> oh yes, I could have thought of that. in JS you can assign a function to
> a property or variable at runtime, even I did something similar, when I
> assign the action functions of the buttons of a modal dialog
> dynamically. it's good because the same simple JS library can handle any
> number of use cases, and my main page with the JS libraries load only
> once, ajax does the rest of stuff, so I could not change the class
> definition for the separate cases.
> but on server side, why not throw everything you might need in the class
> definition?
javascript has this neat concept of execution context. so a single function
can work w/ any 'class' or more precisely, any object.
a = {d : 5};
b = {d : 6};
function c() { alert(this.d); }
c.apply(a);
c.apply(b);
quite interesting.
-nathan