Object of type %s is not callable¶
Description¶
There was an attempt to call a function whose name was provided in a variable, but that value could not be related to a callable code.
null: not a callabletrue,false: booleans are not callableint: integers are not callablereal: real are not callablearray: arrays are callable when they have two elements, with keys 0 and 1. First one is a class or an object of that class, the second is a string with a visible method name on that class. Otherwise, they are not valid callables.string: strings are callable when they represent a function, with the leading backslash,\strlen, or a method, with a class name, a double colon::, and a visible method name. Otherwise, they are not valid callables.object: object are callable when their class has a__invokemethod. This might be through a parent, likeClosure. Otherwise, objects are not callable, although their method are.
All of these may be checked with a call to is_callable() on the variable, before using it.
Example¶
<?php
$method = new stdClass;
$method();
?>
Literal Examples¶
Object of type stdClass is not callable
Object of type X is not callable
Solutions¶
Check the variable with
is_callable(), before using it with the call syntax.Use one of the available format.