Home >Backend Development >PHP Tutorial >python - PHPrpc远程调用,但是每个方法的参数个数不一致,不想写死,怎么搞?

python - PHPrpc远程调用,但是每个方法的参数个数不一致,不想写死,怎么搞?

WBOY
WBOYOriginal
2016-06-06 20:20:15999browse

远程调用如下类方法,但是每个方法的参数个数不一致,不想写死,怎么搞?

<code>class aaaController extends RpcController 
{
    public function one_function($a='', $b='', $c=''){}
    public function two_function($d='', $e=''){}
    public function three_function($f=''){}
}
</code>

回复内容:

远程调用如下类方法,但是每个方法的参数个数不一致,不想写死,怎么搞?

<code>class aaaController extends RpcController 
{
    public function one_function($a='', $b='', $c=''){}
    public function two_function($d='', $e=''){}
    public function three_function($f=''){}
}
</code>

没接触过RPC,不知道是否符合你的问题

方法中接收参数可以用func_get_arg()
5.6版本新添加一个特性,可以用来接收可变个数参数

<code>function concatenate($transform, ...$strings) {
  $string = '';
  foreach($strings as $piece) {
    $string .= $piece;
  }
  return($transform($string));
}
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn