Reputation: 68406
At one point I have:
$callback = array(&$this, 'foo');
How can I find out later if $callback
is the foo method?
if($callback == array(&$this, 'foo'))
doesn't seem to work
Upvotes: 1
Views: 64
Reputation: 2590
<?php
class A
{
public function Test1()
{
$callback = array(&$this, 'foo');
var_dump($callback == array(&$this, 'foo'));
}
public function foo()
{
}
}
$a = new A();
$a->Test1();
?>
Upvotes: 1
Reputation: 239250
Callbacks are just simple arrays, and the method name is a string. Just check the second element of the array:
if ($callback[1] == 'foo')
Upvotes: 2