Weird question but nice idea
Posted: Fri Oct 07, 2005 12:08 pm
Hey,
Anybody know if I can capture the name of a requested (invalid) method and do something with it before php throws an error?
I'm playing around with some funky dynamic variable/function stuff and this could be very useful to me.
Example:
This is more a proof of concept but that last $foo->y(); I'd like to capture the fact that they requested a method called "y" and do something with it.... My guess is that this is impossible 
Anybody know if I can capture the name of a requested (invalid) method and do something with it before php throws an error?
I'm playing around with some funky dynamic variable/function stuff and this could be very useful to me.
Example:
Code: Select all
class foo
{
private $x = 5;
private $y = 13;
public function x($z)
{
$this->{__FUNCTION__} = $z; //Cool
}
public function showx()
{
echo $this->x;
}
}
$foo = new foo();
$foo->showx(); //5
$foo->x(29);
$foo->showx(); //29
$foo->y(16); //PHP gives an error (rightfully so)