1

I struggle to understand how I can add a second parameter ($id) to pass along with this callback in my php class:

($this, 'updateDuplicateAcronym')

The method updateDuplicateAcronym should recieve 2 parameters, one by reference from the form where this code belongs (which works fine), and one more that I need in order to do some checks.

Someone who knows how to do this?

1
  • I'm not sure what the hard part of this is, updateDuplicateAcronym is your function declaration, so it is based on the arguments that function expects. Commented Feb 16, 2015 at 16:41

1 Answer 1

2

Here is my method to pass parameters :

$callBackFunction = function($p1, $p2) {
    ...
}

baseFunction($context, $callable, $params) 
{
    //Main process

    call_user_func($callable, $params);
}

// Running
baseFunction($this, $callBackFunction, array(1, 42));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.