I saw a code like this:
function($cfg) use ($connections) {}
but php.net does not seem to mention this feature. I guess this is related to scope, but how?
use not a function; it is part of the closure syntax. It simply makes the specified variables of the outer scope available inside the closure.
use
$foo = 42; $bar = function () { // can't access $foo in here echo $foo; // undefined variable }; $baz = function () use ($foo) { // $foo is made available in here by use() echo $foo; // 42 }
For instance:
$array = array('foo', 'bar', 'baz'); $prefix = uniqid(); $array = array_map(function ($elem) use ($prefix) { return $prefix . $elem; }, $array); // $array = array('4b3403665fea6foo', '4b3403665fea6bar', '4b3403665fea6baz');
Tells an anonymous function to make $connections (the parent variable) available in its scope.
$connections
Without it, $connections will not be defined inside the function.
Documentation
Source: https://habr.com/ru/post/900011/More articles:It is not possible to call the supertype constructor directly - why not? - javaCorrect way to convert char * to NSString without initWithCString? - ioshttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/900008/mysql-error-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax&usg=ALkJrhhOYdvsDbAdYVtAaXsd_juaHWBB6wCapturing the contents of standard output in C # - c #OpenGL Alpha Blending - openglUsing lawn adapters - javascript"Password" appears as "********" in IE for the alternate - javascriptAdmob with Android: unable to parse android: configChanges in manifest - androidGridView or TableLayout? - androidFacebook asks 2.0, how do I change the Accept button URL to be a non-Facebook URL? - javascriptAll Articles