<?php function genFunc($name) { return function($msg) use($name) { echo $name . ' --- ' . $msg; }; } $func = genFunc("tom"); //var_dump($f); $func(" hello ");
A simple example of PHP closure
最新推荐文章于 2023-07-19 16:18:55 发布
<?php function genFunc($name) { return function($msg) use($name) { echo $name . ' --- ' . $msg; }; } $func = genFunc("tom"); //var_dump($f); $func(" hello ");