简写if / else php不能继续

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简写if / else php不能继续相关的知识,希望对你有一定的参考价值。

如果第二个或第三个是假的,如何进入下一个参数事件?在我的情况下genderfalsemarital statustrue但他们停在gender而不执行marital status。我如何让它继续下一个参数事件第二或第三是false

public function creditScore($user, $basic_information)
    {
        $basic_information->birth_date ? dispatch(new CalculateAge($user)) : false;
        $basic_information->dependents ? dispatch(new CalculateDependents($user)) : false;
        $basic_information->education ? dispatch(new CalculateEducation($user)) : false;
        $basic_information->gender ? dispatch(new CalculateGender($user)) : false;
        $basic_information->marital_status ? dispatch(new CalculateMaritalStatus($user)) : false;
    }
答案

使用

if (isset($basic_information->birth_date)) dispatch(new CalculateAge($user));

以上是关于简写if / else php不能继续的主要内容,如果未能解决你的问题,请参考以下文章