Using return in ternary operator

前端 未结 7 911
無奈伤痛
無奈伤痛 2020-12-03 17:46

I\'m trying to use return in a ternary operator, but receive an error:

Parse error: syntax error, unexpected T_RETURN 

Here\'s the code:

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 18:03

    No, that's not possible. The following, however, is possible:

    $e = $this->return_errors();
    return ( !$e ) ? '' : array( false, $e );
    

    Hope that helps.

提交回复
热议问题