Closure
is
checks whether the unknown parameter is of type closure object.
Closure::is(mixed $mUnknown) : bool
Example
// a closure
$oClosure = function () {
display('I am a Closure.');
};
// check
$bIsClosure = Closure::is($oClosure);
// bool(true)
var_dump($bIsClosure);
Result
true
toString
with the Closure::toString
method you can convert a Closure into a String, which is useful if you want to log a closure into a logfile for example.
Closure::toString(\Closure $oClosure, bool $bShrink = true) : string
Example
// a closure
$oClosure = function () {
display('I am a Closure.');
};
$sClosure = Closure::toString($oClosure);
// string(43) "function () { display('I am a Closure.'); }"
var_dump($sClosure);
Result
function () { display('I am a Closure.'); }