Fermeture PHP :: appel ()

Closure::call() de PHP 7 a de meilleures performances, liant dynamiquement une fonction de fermeture à une nouvelle instance d'objet et appelant la fonction.

Instance

x; }; // 闭包函数绑定到类 A 上 $getX = $getXCB->bindTo(new A, 'A'); echo $getX(); echo "
"; // PHP 7+ 代码 $getX = function() { return $this->x; }; echo $getX->call(new A); ?>

Le résultat de l'exécution du programme ci-dessus est :

1 1
Formation continue
||
x; }; // 闭包函数绑定到类 A 上 $getX = $getXCB->bindTo(new A, 'A'); echo $getX(); echo "
"; // PHP 7+ 代码 $getX = function() { return $this->x; }; echo $getX->call(new A); ?>
soumettre Réinitialiser le code
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!