PHP two methods with the same name

前端 未结 4 958
借酒劲吻你
借酒劲吻你 2021-02-07 14:04

Can I have two methods sharing the same name, but with different arguments?

One would be public static and would take 2 arguments, the other one just public and takes on

4条回答
  •  天涯浪人
    2021-02-07 14:43

    No. PHP does not support classic overloading. (It does implement something else that is called overloading.)

    You can get the same result by using func_get_args() and it's related functions though:

    function ech()
    {
      $a = func_get_args();
      for( $t=0;$t

提交回复
热议问题