One of the "neat" things in Javascript is you are able to dynamically add or change methods of a class and automatically update every instance of that class. Some of the things I usually find useful are adding to the String class, like so:
Obviously we cannot do this in PHP, and why would we, right? However we can emulate this behaviour to a certain extent using my "neat" little [Prototype](http://pastoid.com/9n+) class. With this Prototype class we can dynamically add properties and methods to any class, and they will ...
Wait, What? Yeah that's what I thought too. Still no Idea what I'm talking about? Well, let's take a look at the following code. Let's call it "fred".
class foo {
function bar( $b = 0 )
{
static $a = 0;
if ( $b ) {
$a = $b;
}
echo $a;
}
}
$faz = new foo;
$faz->bar(3);
$baz = new foo;
$baz->bar();
foo::bar();
foo:bar(1);
$faz->bar();
The code above, named "fred", basically creates a static variable $a inside the function foo(). When you call foo(0) it outputs the value of $a. When you call foo('x') , ...
I would like to introduce Drunken Monkey Labs. My new site to host and support all of my coding and web projects. This site will become solely my personal blog. Simplifying the orginizational aspects of the site and truly making mattread.* the personal site of Matt Read, me, as it says.
If you are looking for any of my projects, formely hosted here, check Drunken Monkey Labs and expect to see some pretty cool stuff coming out of the labs.