PHPverse 2025

Voting

: min(eight, one)?
(Example: nine)

The Note You're Voting On

Hayley Watson
1 year ago
If you have a closure (or other callable) stored in an object property and you want to call it, you can use parentheses to disambiguate between it and a method call:

<?php
class Test
{
public
$callable;

function
__construct()
{
$this->callable = function($a) { return $a + 2; };
}
}

$t = new Test;

echo (
$t->callable)(40);
?>

<< Back to user notes page

To Top