Array Callback
An array callback is an array of two elements, which may be used as a callback function.
The array must have only two elements: the first one is a class name or an object, and the second one is a method name. Then, the method on the class or object is called, when used with the class functioncall syntax.
The array should not use any string keys. It should only use index 1 and 0, although they may be in wrong order.
<?php
class Elephpant {
function trumpet() { echo __METHOD__; }
static function stampede() { echo __METHOD__; }
}
$method = [new Elephpant, 'trumpet'];
$method(); // Elephpant::trumpet
$method = [1 => 'trumpet', 0 => new Elephpant]; // 1 and 0 keys, but wrong order
$method(); // Elephpant::trumpet
$staticMethod = [Elephpant::class, 'stampede'];
$staticMethod(); // Elephpant::stampede
$staticMethod2 = ['\Elephpant', 'stampede'];
$staticMethod2(); // Elephpant::stampede
?>