NYCPHP Meetup

[nycphp-talk] Intellectual Monday

Billy Reisinger billy.reisinger at gmail.com
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
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070122/24a1a68c/attachment.html>


More information about the talk mailing list