This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".  
Status: 2023-12-28

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.'); }