如何在 PHP 中将多个参数传递给匿名函数?

Ant*_*dge 5 php callback anonymous-function

PHP 5.3+ 支持匿名函数(尽管在 PHP 7.x+ 中,它对匿名函数的支持在绑定方面略有不同)。我正在运行 PHP 5.6.x

是否有一种语法允许将多个参数传递给用作回调的匿名函数(而不是仅使用数组。以下哪些示例(如果有)可以在 PHP 中实现?

实施例1

function ($str1, $str2 ){   //But, that would be too easy, right?
    return $str1 . $str2;
}
Run Code Online (Sandbox Code Playgroud)

实施例2

function () use ($string, $min, $max) {  // Not seeing this in the manual.
    $length = mb_strlen($string, 'UTF-8');
    return ($length >= $min) && ($length <= $max);
}
Run Code Online (Sandbox Code Playgroud)

实施例3

只是出于好奇,这种形式可能吗?

function ($str1, $str2 ) use ($int1, $int2) { // But, that would be in the manual?
    return $str1 . $str2 .' '. $int2 + $int2;
}
Run Code Online (Sandbox Code Playgroud)

我查看了 PHP 手册,但没有看到我要找的东西。

小智 0

示例 2 对我有用。

function () use ($string, $min, $max) {  // Not seeing this in the manual.
    $length = mb_strlen($string, 'UTF-8');
    return ($length >= $min) && ($length <= $max);
}
Run Code Online (Sandbox Code Playgroud)