Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP functions needs return any value?

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?

like image 837
Henrique Avatar asked Dec 05 '22 19:12

Henrique


2 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.

like image 124
icktoofay Avatar answered Dec 10 '22 09:12

icktoofay


No, returning a value from a function does not improve the speed of your script.

You do not need to return values from functions -> it is completely optional.

like image 34
Jacob Relkin Avatar answered Dec 10 '22 09:12

Jacob Relkin