During programming, you must call functions or methods frequently. To ensure program robustness, you generally need to judge the return values of functions (especially for functions that return bool values ), but do I have to judge the return value every time I call a function? In this way, not only do you think it is cumbersome, but you will also get the program code... during programming, you must call functions or methods frequently. To ensure program robustness, you generally need to judge the return values of functions (especially for functions that return bool values ), but do I have to judge the return value every time I call a function? In this case, it is not only complicated, but also the program code is full of judgment statements. So I would like to ask when the return value should be determined when a function (method) is called, when is it not required? Thanks :)
Reply content:
During programming, you must call functions or methods frequently. To ensure program robustness, you generally need to judge the return values of functions (especially for functions that return bool values ), but do I have to judge the return value every time I call a function? In this case, it is not only complicated, but also the program code is full of judgment statements. So I would like to ask when the return value should be determined when a function (method) is called, when is it not required? Thanks :)
Looking forward to php7
Function test (int $ a, int $ B): bool {return $ a> $ B ;}
Yes. It's just a little worth the candle.
In the function, any unsuccessful processing throws an exception. You do not need to judge whether to call this function.
Php is a weak language. In the code, if (function_name ($ params) {} is usually used to determine whether the returned value is needed. There is no need to worry too much about it.