[nycphp-talk] Intellectual Monday

Billy Reisinger billy.reisinger at
Mon Jan 22 20:45:32 EST 2007

I got nothing on chaining, but I have some opinions about the  
prototype concept.
The prototyping concept in general is similar to using a static  
member in Java.  A function prototype in JavaScript is a member that  
is common to all instances of that function (read: class).  If one  
instance decides to change that prototype, all instances of that  
function immediately inherit that change.   Additionally, the  
prototype resides in a single spot in physical memory (supposedly),  
such that every new copy of a function uses the same set of  
prototypes.  I'm not a PHP expert, but I imagine there is a similar  
concept in PHP....
One of the problems I've run into with javascript in a production  
environment is that it actually allows you to extend native objects,  
which themselves are just functions.   Extending native objects (i.e.  
Function, Object, Array, Element, etc.) can lead to unexpected errors  
when your code interacts with an outside environment.  Just to give  
you an example, extending the Array class with custom methods leads  
to these methods appearing as entries for every array in foreach  
loops.  Probably not what you wanted.
AFAIK, PHP doesn't allow you to extend native objects like JavaScript  
does.  Probably a good thing, anyway.

On Jan 22, 2007, at 12:49 PM, Cliff Hirsch wrote:

> I have been digging into JavaScript and jQuery, and am intrigued by  
> several concepts.
> 1. jQuery uses chaining, whereby every method within jQuery returns  
> the query object itself.
> 2. JavaScript's prototype method is an interesting concept for  
> adding methods to existing classes.
> I wonder how these techniques work in the PHP world. Does anyone  
> use chaining effectively? Is there a PHP equivalent to the  
> prototype concept?
> Cliff
> _______________________________________________
> New York PHP Community Talk Mailing List
> NYPHPCon 2006 Presentations Online
> Show Your Participation in New York PHP

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list