Link to home
Start Free TrialLog in
Avatar of Rozamunda
Rozamunda

asked on

pointers to static methods

Hi, I defined pointers to 3 different static methods

 if ($cond1)
   $crtrow = function () { return DD::cuctrowch(); };

 if ($cond2)
   $crtrow = function () { return DD::cuctrow(); };

 if ($cond3)
   $crtrow = function () { return DD::cuctrowp(); };


class DD
 static function  cuctrow($row)
 {

 }
 static function  cuctrow($row)
 {

 } 
..
..
}

Open in new window


each of those function requires a parameter. however when i call $crtrow($row)

i am getting an error that function

DD::cuctrow() requires parameter, which I am passing
Avatar of kaufmed
kaufmed
Flag of United States of America image

My guess is that you are saying "function () ..." which means you aren't declaring that the anonymous function takes a parameter at all. Sure, the function that is being called in the body of that anonymous function does, but you have not provided a way for the anonymous function to receive a parameter.

In short, instead of "function ()..." try "function ($row)...".

...and you'll also need to pass that parameter.

e.g.

if ($cond3)
   $crtrow = function ($row) { return DD::cuctrowp($row); };

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial