Close check screen
We have an anonymous function in stdclass object like the following code:
$std = new \stdclass();
$std->method = function(){echo "Hi I'm instance of Closure.";};
echo get_class($std->method); // prints "Closure"
if ($std->method instanceof Closure) {
echo "Happy Ending."; // This line never gets executed.
}
the anonymous function is an instance of the Closure class, but when I inspect it with a keyword instanceof
it doesn't return true. what is the problem?
+3
source to share