In PHP
PHP 5.3+ has first-class functions that can be used e.g. as parameter to the usort function:
$a = array(3, 1, 4); usort($a, function ($x, $y) { return $x - $y; });It is also possible in PHP 5.3+ to make a class invokable, but this is rarely used:
class Minus { public function __invoke($x, $y) { return $x - $y; } } $a = array(3, 1, 4); usort($a, new Minus);Read more about this topic: Function Object