php returning mixed data types - good or bad

后端 未结 7 686
梦谈多话
梦谈多话 2021-02-02 14:34

When returning values in php, is it considered good or bad practice to return mixed data types. I\'m working on a project where I am constantly faced with methods that return a

7条回答
  •  礼貌的吻别
    2021-02-02 15:11

    I agree with the answers above.

    However if you design a whole system, the "best practice" would be to use exceptions: always return something meaningful, and in case of anomaly, throw an exception. The caller can then deal with the situations he knows how to face, and let somebody higher catch the rest.

提交回复
热议问题