PHP Function

Functions are used to reduce the repetition of codes in your scripts.

The user define function are starts with function tag.

The function name should not start with numbers ( 0 – 9 ). The allowed format is letters ( a-z, A-Z )  and underscores ( _ ).

Beginning with curly braces (  {  ) indicates the function get start to execute the block of code under the function. Closing curly braces ( } ) indicates the closing / end of the function.

<?php
     function cityDetails($city){
         echo "Am staying in $city";
         echo "<br />";
     }

     cityDetails("New York");
     cityDetails("Los Angeles");
?>

Output:
Am staying in New York
Am staying in Los Angeles
<?php
     function add($a,$b){
       $c = $a + $b;
       return $c;
     }
     function sub($a,$b){
       $c = $a - $b;
       return $c;
     }
     function mul($a,$b){
       $c = $a * $b;
       return $c;
     }

    $addingValues = add(25,15);
    $subtractingValues = sub(30,10);
    $multiplicationValues = mul($addingValues,$subtractingValues);
    echo "Multiplication Value is :: $multiplicationValues";
?>

Output :
Multiplication Value is :: 800

// addition value is 40
// subtraction value is 20
// Multiplication of both the data will be 40 * 20 = 800

For more info please refer php.net functions section.