ch3.org.uk

Get Firefox!

Just a little radical?

OOP coding query

2007-01-04 17:24:00
PHP, with a flamboyant disregard for static/dynamic separation, allows me to do the following:

class thingy{
static function boo() { print('BOO'); }

function bang() { print('BANG'); }
}

$myThing=new thingy();
thingy::bang();
$myThing->boo();

ie, it makes no effort to stop me calling static functions (or members) in a dynamic (and probably misleading) fashion. I'd expect $myThing->boo() to throw a (probably fatal) error saying something like "Static method called dynamically". Without this protection, I'd suspect that allocations to a static variable from inside an object would cause changes not merely within the object scope, but within all objects *and* the class scope, which feels like a world-class "gotcha" waiting to happen.


Is this common among OOP languages, or is this just another example of PHP's juvenile status?

Post new comment

Subject:
Your name:
Your email:
The number above:
Hide email address:
Email me replies:
Format: [TEXT]
Message:

<< First | < Previous | Next > | Last >>