0
1

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 5 years have passed since last update.

【php】戻り値【return】

Posted at

return

関数は値を返すことが可能。その値を戻り値と呼ぶ。
関数を実行した結果、その関数実行部分が戻り値に置き換わるイメージ。
「return」で指定する。

//関数の定義
function getSum($num1,$num2){
  return $num1 + $num2;
}

//関数の呼び出し
$num = getSum(2,3);
echo $num; //結果: 5

//実行されると、値が戻り値(2+3)に置き換わる
0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?