在php中为变长参数列表传递变量

在php中为变长参数列表传递变量,php,Php,我想实现我自己的调试函数,它与sprintf()函数具有相同的签名,sprintf()函数具有变量arg list: sprintf('[%s] [%s]', 'textA','textB'); sprintf('[%s]', 'textC'); 以上两种方法都有效 现在我想要一个类似的调试函数,它可以将自己的参数列表传递给sprintf() 任何人都可以告诉我,如果A是可变长度参数,我如何将A传递给sprintf 提前谢谢 function debug() { $args =

我想实现我自己的调试函数,它与sprintf()函数具有相同的签名,sprintf()函数具有变量arg list:

sprintf('[%s] [%s]', 'textA','textB');  
sprintf('[%s]', 'textC');
以上两种方法都有效

现在我想要一个类似的调试函数,它可以将自己的参数列表传递给sprintf()

任何人都可以告诉我,如果A是可变长度参数,我如何将A传递给sprintf

提前谢谢

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

看看:

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