php - Call_user_func_array() expects parameter 1 to be a valid callback (Event handler system) -


I'm trying to create a system that handles the supply went data and Adhandlr ().

Code:

  class test {public $ arrHandlers = array (); Public function addHandler ($ action, $ function) {$ this- & gt; ArrHandlers [$ action] = $ function; } Public function handle data ($ data) {$ data = explosion ("/", $ data); $ Action = array_shift ($ data); If (isset ($ this-> arrHandlers [$ action])) {call_user_func_array ($ this-> orientation [$ verb], array ($ data)); }}} Function testFunc () {echo fonts ("", fenc_gate_arg ()); } $ Obj = New Test (); $ Data = "egg / me / liked / cheese"; $ Obj- & gt; Edhandler ("eggs", "testfunk"); $ Obj- & gt; HandleData ($ data);  

What this output is:

  Warning: call_user_func_array () expects parameter is valid callback 1, an array of on line 13 Is not a string  

I want it to output:

  I like cheese  

working code:

  class test {public $ arrHandlers = array (); Public function addHandler ($ action, $ function) {$ this- & gt; ArrHandlers [$ action] = $ function; } Public function handle data ($ data) {$ data = explosion ("/", $ data); $ Action = array_shift ($ data); If (isset ($ this-> arrHandlers [$ action])) {call_user_func_array ($ this-> arrHandlers [$ action], $ data); }}} Function testFunc () {echo fonts ("", fenc_gate_arg ()); } $ Obj = New Test (); $ Data = "eggs / me / likes / cheese"; $ Obj- & gt; Edhandler ("eggs", "testfunk"); $ Obj- & gt; HandleData ($ data); The  

I ' arrHandlers ' rather than ' arrhandlers put and $ data' array ($ data) Instead of ' $ data ' instead of ' call_user_func_array () passed in the form.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -