1. Go to this page and download the library: Download jeremeamia/superclosure library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeremeamia / SuperClosure example snippets
use SuperClosure\Serializer;
$serializer = new Serializer();
$greeting = 'Hello';
$hello = function ($name = 'World') use ($greeting) {
echo "{$greeting}, {$name}!\n";
};
$hello('Jeremy');
//> Hello, Jeremy!
$serialized = $serializer->serialize($hello);
// ...
$unserialized = $serializer->unserialize($serialized);
$unserialized('Jeremy');
//> Hello, Jeremy!
use SuperClosure\Serializer;
use SuperClosure\Analyzer\AstAnalyzer;
use SuperClosure\Analyzer\TokenAnalyzer;
// Use the default analyzer.
$serializer = new Serializer();
// Explicitly choose an analyzer.
$serializer = new Serializer(new AstAnalyzer());
// OR
$serializer = new Serializer(new TokenAnalyzer());
$serializer1 = new SuperClosure\Serializer(null, $yourSecretSigningKey);
$data = $serializer1->serialize(function () {echo "Hello!\n";});
echo $data . "\n";
// %rv9zNtTArySx/1803fgk3rPS1RO4uOPPaoZfTRWp554=C:32:"SuperClosure\Serializa...
$serializer2 = new SuperClosure\Serializer(null, $incorrectKey);
try {
$fn = $serializer2->unserialize($data);
} catch (SuperClosure\Exception\ClosureUnserializationException $e) {
echo $e->getMessage() . "\n";
}
// The signature of the closure's data is invalid, which means the serialized
// closure has been modified and is unsafe to unserialize.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.