php returning mixed data types - good or bad

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

    What I usually do is if the method worked, return the value, and if it failed return FALSE. That's what a lot of PHP's built-in methods do. So, then you can just check if the function returned FALSE or not.

提交回复
热议问题