a) it is mandatory to define a return statement in a user-defined function.?
Not. Sometimes you write functions that return nothing to the called function, say, a function to print a multidimensional array is pretty nice.
b), does it remain valid if I just define a return statement without any parameter? will it return a null value?
Yes. Omitting return same as return without any parameters, and both return NULL .
c) there is the following function:
Syntactically correct. But it would be more meaningful if you return a boolean to indicate the success / failure of the request. In order for the caller to know that the database update was normal or not.
EDIT:
"UPDATE admins SET password = '$password'"
The request is missing a WHERE . Therefore, it effectively updates the password of all users in the admins table.
source share