Multiple returns from a function

后端 未结 30 2310
盖世英雄少女心
盖世英雄少女心 2020-11-22 06:12

Is it possible to have a function with two returns like this:

function test($testvar)
{
  // Do something

  return $var1;
  return $var2;
}
<
30条回答
  •  情话喂你
    2020-11-22 06:40

    Best Practice is to put your returned variables into array and then use list() to assign array values to variables.

    ';
    echo "Subtract: " . $subt_result . '
    '; ?>

提交回复
热议问题