Get variables from the outside, inside a function in PHP

前端 未结 7 1922
时光说笑
时光说笑 2020-12-03 06:31

I\'m trying to figure out how I can use a variable that has been set outside a function, inside a function. Is there any way of doing this? I\'ve tried to set the variable t

相关标签:
7条回答
  • 2020-12-03 07:33
    $var = '1';
    function addOne() use($var) {
       return $var + 1;
    }
    
    0 讨论(0)
提交回复
热议问题