note 101181 modified in function.is-callable by danbrown
| From: | danbrown@php.net | Date: | Wed, 01 Dec 2010 15:12:20 +0000 |
| Subject: | note 101181 modified in function.is-callable by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174525@lists.php.net to get a copy of this message | ||
It's worth noting that passing an object and method name will not work for lambdas/closures
stored within an object property. Here's a test case in 5.3.3.
<?php
class TestClass
{
public $testMethod;
public function __construct()
{
$this->testMethod = function(){};
}
}
$test = new TestClass();
is_callable(array($test, 'testMethod')); // false
is_callable($this->testMethod); // true
?>
--was--
It's worth noting that passing an object and method name will not work for lambdas/closures
stored within an object property. Here's a test case in 5.3.3.
<?php
class TestClass
{
public $testMethod;
public function __construct()
{
$this->testMethod = function(){};
}
}
$test = new TestClass();
is_callable(array($test, 'testMethod')); // false
is_callable($this->testMethod); // true
http://php.net/manual/en/function.is-callable.php