mentors

mentors Git Source Tree


Root/vendor/jeremeamia/SuperClosure/demo/hello-world.php

<?php

require __DIR__ . '/../vendor/autoload.php';

use Jeremeamia\SuperClosure\SerializableClosure;

$greeting = 'Hello';
$helloWorld = new SerializableClosure(function ($name = 'World') use ($greeting) {
    echo "{$greeting}, {$name}!\n";
});

$helloWorld();
//> Hello, World!
$helloWorld('Jeremy');
//> Hello, Jeremy!

$serialized = serialize($helloWorld);
$unserialized = unserialize($serialized);

$unserialized();
//> Hello, World!
$unserialized('Jeremy');
//> Hello, Jeremy!

Archive Download this file

Branches

Number of commits:
Page rendered in 0.12140s using 11 queries.