Ellipsis (computer programming): Difference between revisions

Content deleted Content added
Line 94:
int(5)
}
</syntaxhighlight>
 
Since PHP 8.1, a nullary ellipsis may be used to create a [[closure (computer programming)|closure]] from a callable or an object method:<ref>{{Cite web |title=PHP 8.1.0 Release Announcement |url=https://www.php.net/releases/8.1/en.php#first_class_callable_syntax |access-date=2023-03-29 |website=php.net}}</ref>
 
<syntaxhighlight lang="php">
// old style: PHP 8.0 and older
$foo = [$this, 'foo'];
$fn = Closure::fromCallable('strlen');
 
// new style: PHP 8.1 and newer
$foo = $this->foo(...);
$fn = strlen(...);
</syntaxhighlight>