2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PHPで引数を可変長で渡すテストプログラムを実装しました。

 // 可変長引数で合計を計算する
    function sum(...$numbers)
    {
      $total = 0;
      foreach($numbers as $number){
        $total += $number;
      }
      return $total;
    }

    // ブラウザ表示
    function disp($num){
      echo "<p class=test1>${num}</p>";
    }

    $total1 = sum(3,4,5);
    disp($total1);

    $total2 = sum(1,3,5,7,9,11);
    disp($total2);

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?