Closures in PHP… what, precisely, are they and when would you need to use them?

前端 未结 8 1497
囚心锁ツ
囚心锁ツ 2021-01-29 20:50

So I\'m programming along in a nice, up to date, object oriented fashion. I regularly make use of the various aspects of OOP that PHP implements but I am wondering when might I

8条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 21:28

    Bascially,Closure are the inner functions tat have access to the outer variables and are used as a callback function to anonmyous function (functions that do not have any name).

     
    
    //output captain
    
    //and if we pass variable as a reference as(&$param) then output would be spider man;
    

提交回复
热议问题