mirror of
https://github.com/php/php-src.git
synced 2024-12-01 22:03:36 +08:00
52 lines
1017 B
Plaintext
52 lines
1017 B
Plaintext
|
--TEST--
|
||
|
Closure 016: closures and is_callable()
|
||
|
--FILE--
|
||
|
<?php
|
||
|
class Foo {
|
||
|
function __invoke() {
|
||
|
echo "Hello World!\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function foo() {
|
||
|
return function() {
|
||
|
echo "Hello World!\n";
|
||
|
};
|
||
|
}
|
||
|
$test = new Foo;
|
||
|
var_dump(is_callable($test, true, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable($test, false, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable(array($test,"__invoke"), true, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable(array($test,"__invoke"), false, $name));
|
||
|
echo $name."\n";
|
||
|
$test = foo();
|
||
|
var_dump(is_callable($test, true, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable($test, false, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable(array($test,"__invoke"), true, $name));
|
||
|
echo $name."\n";
|
||
|
var_dump(is_callable(array($test,"__invoke"), false, $name));
|
||
|
echo $name."\n";
|
||
|
?>
|
||
|
--EXPECT--
|
||
|
bool(true)
|
||
|
Foo::__invoke
|
||
|
bool(true)
|
||
|
Foo::__invoke
|
||
|
bool(true)
|
||
|
Foo::__invoke
|
||
|
bool(true)
|
||
|
Foo::__invoke
|
||
|
bool(true)
|
||
|
Closure::__invoke
|
||
|
bool(true)
|
||
|
Closure::__invoke
|
||
|
bool(true)
|
||
|
Closure::__invoke
|
||
|
bool(true)
|
||
|
Closure::__invoke
|