1. 程式人生 > >PHP(匿名函式)閉包可以從父作用域中繼承變數

PHP(匿名函式)閉包可以從父作用域中繼承變數

用 use 語言結構傳遞進去

<?php
// Closures can also accept regular arguments
$example = function ($arg) use ($message) {
    var_dump($arg . ' ' . $message);
};
$example("hello");
?>