Is it necessary to return any value or does it improve the speed? Sometimes its needed to code functions that not necessary return a value, some just do a set of functions or echo something. Does returning a value improves 'something'?, something like return true or return false?
3 Answers
PHP functions do not need to return anything, and I doubt it would negatively affect the performance if you didn't return anything. If anything, it would positively affect the performance.
2 Comments
user3253002
Can you show how returning "anything" would affect the performance positively?
icktoofay
@user3253002: I think I meant that if anything, not returning anything might improve the performance. But honestly I don't think you would be able to measure a difference either way -- it is such a small detail that it would almost certainly be overwhelmed by anything else in your script.
but, if you omit the "return something;" command the implicit returned value will be NULL
1 Comment
john Smith
Good info for adding the correct return type declarations