Is it possible to have a function with two returns like this:
function test($testvar)
{
// Do something
return $var1;
return $var2;
}
<
Its not possible have two return statement. However it doesn't throw error but when function is called you will receive only first return statement value. We can use return of array to get multiple values in return. For Example:
function test($testvar)
{
// do something
//just assigning a string for example, we can assign any operation result
$var1 = "result1";
$var2 = "result2";
return array('value1' => $var1, 'value2' => $var2);
}