Reputation: 6680
Is there a built-in class function
which instances are the standard PHP functions? Are PHP functions objects?
In Python I can test it in this way:
from inspect import isclass
def foo():
pass
isclass(type(foo))
>>> True
What about this function in PHP:
function foo(){
return null;
}
Upvotes: 2
Views: 337
Reputation: 3569
Anonymous functions are objects of "Closure" class. Here is the test:
$myfunction = function(){
echo "Hi";
};
if(is_object($myfunction)){
echo get_class($myfunction); //prints 'Closure'
}
Upvotes: 6