$this is Out of Context
I’ve stumbled across some strange behavior in PHP 5 when calling a class method statically from an Exception’s constructor. In PHP, you’re not required to label a class’s function as static but you are still able to use it as a static function. Example:
<?php
class MyClass {
public function MyFunction() {
echo "You called MyClass's MyFunction";
}
}
MyClass::MyFunction();
?>
Now, the strange little … behavior I have noticed is that when you call a method statically from an instance of an Exception’s constructor, $this always references the instance of the Exception object. Read the rest of this entry »