View Single Post
  #51 (permalink)  
Old 05-09-2008, 05:17 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: Operations in PHP

Hi,

User-Defined Functions

The general way of defining a function is
function function_name (arg1, arg2, arg3, …)
{
statement list
}
To return a value from a function, you need to make a call to return expr
inside your function. This stops execution of the function and returns expr as
the function’s value.
The following example function accepts one argument, $x, and returns its
square:
function square ($x)
{
return $x*$x;
}
After defining this function, it can be used as an expression wherever you
desire.
For example:
print 'The square of 5 is ' . square(5);
__________________
Regards,
Senraj.A
Reply With Quote