1

I wanted to implement my own debug function that has the same signature as sprintf() function which has a variable arg-list:

sprintf('[%s] [%s]', 'textA','textB');  
sprintf('[%s]', 'textC');

both above will work.

now I want to has a similar debug function that can pass its own arg-list to sprintf():

function debug(A) {
      $msg = sprintf(A);
      ...
}

anyone can tell me how can I pass A to sprintf if A is variable length argument.?

thanks in advance!

2 Answers 2

2
function debug() {
      $args = func_get_args();
      $msg = call_user_func_array('sprintf', $args);
}

CodePad.

Sign up to request clarification or add additional context in comments.

Comments

1

Have a look at:

and

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.