Functions
The use of functions enables us to group several statements under only one name and to call them several times from different places, saving us the need to rewrite them.
<?php
function Nombre(param1, param2...)
{
statement1;
statement2;
statement3;
statement4;
return return_value;
}
?>
We can optionally pass parameters to the functions to be known as local variable, and we can also return a result with the "return value" statement. This produces the ending of the function returning a value.
<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php
function media_aritmetica($a, $b)
{
$media=($a+$b)/2;
return $media;
}
echo media_aritmetica(4,6),"<br>";
echo media_aritmetica(3242,524543),"<br>";
?>
</body>
</html>