PHP code example of phplang / scope-exit
1. Go to this page and download the library: Download phplang/scope-exit 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/ */
phplang / scope-exit example snippets
function f(&$x) {
$x = 1;
$_ = new \PhpLang\ScopeExit(function() use (&$x) { $x = 2; });
// $x is still 1 at this point.
return 42;
// After the return, the local scope is cleaned up, the closure is invoked, and it's set to 2
}
f($a);
var_dump($a); // int(2)