php returning mixed data types - good or bad

后端 未结 7 689
梦谈多话
梦谈多话 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:15

    Null is a fairly common return value to indicate that there is no return value. You should return null (not "failed", or -1) if the function wants to return no ID at all.

    If it is exceptional that an ID was not found, you should throw an exception.

    0 讨论(0)
提交回复
热议问题