I don't quite understand the $query variable of 'automatic global instantiation” in closure queries.
土豆
土豆 2018-06-07 23:21:09
0
3
1020

Why not use dependency injection in closures? For example,

function(\think\db\Query $q) {

$q->where('sex', 0)->where('salary', '> ', '8000');

}

tp5.1, I can execute it successfully like this.


土豆
土豆

reply all(1)
亚连

This is an anonymous function, not a closure

  • reply PHP manual, definition of anonymous function, The first sentence, "Anonymous functions, also known as closures, (Anonymous functions, also known as closures.)" Manual address: http://php.net/manual/en/functions.anonymous.php I know that the definition of closure in js is "a function that has access to variables in the scope of another function", but in php, closure seems to be the same thing as anonymous function.
    土豆 author 2018-06-08 13:22:45
  • reply Theoretically, closure and anonymity are different concepts, but PHP seems to combine them. Anonymity is closure, and closure is anonymity. You can read this article http://www.php.cn/php-weizijiaocheng-401974.html
    亚连 author 2018-06-08 15:36:17
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template