PHP Closures scoping of variables

后端 未结 3 1210
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 16:15

I am looking at the PHP example of Closures on http://us1.php.net/manual/en/functions.anonymous.php

It provides the example code below and states:

3条回答
  •  天涯浪人
    2021-01-18 16:45

    The closure arguments $quantity and $product do not exist per se in the function definition, they are just placeholders that array_walk will fill with real values during its execution procedure. The use arguments are extra variables that you import into the array_walk call's scope that otherwise would not be available to the function.

提交回复
热议问题