Returning valuesValues are returned by using the optional return statement. Any type may be returned, including arrays and objects. This causes the function to end its execution immediately and pass control back to the line from which it was called. See return for more information.
Use of return
Example #1 Use of return
A function can not return multiple values, but similar results can be obtained by returning an array.
Example #2 Returning an array to get multiple values
To return a reference from a function, use the reference operator & in both the function declaration and when assigning the returned value to a variable:
Example #3 Returning a reference from a function
For more information on references, please check out References Explained. |