Using Functions to Return Values

Up to this point, you have experimented with user-defined functions that do not return values. The traditional black-box value of functions is that inputs are processed into meaningful outputs. The outputs are return values from functions. The broadest prototype of a function that returns any data type is

mixed function my_function(mixed var);

This prototype basically says that the function has a single input of a variable that may be any data type and returns a variable of any data type. Unfortunately, many functions work accidentally this way because of careless type management of return values.

Function return types are provided by using the return keyword, a variable or literal value, and a semicolon. You ...

Get Oracle Database 10g Express Edition PHP Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.