This page explains functions
Functions allow you to program complex tasks. For example, you want to update a score. Using this code: $user = "Alex";
$score = 100;
function updateScore(){
echo "The current user is " . $GLOBALS['user'] . " and their score is " . $GLOBALS['score'] ;
$GLOBALS['score'] += 50;
}
updateScore();
echo " New score: " . $score . "
";
This will be the results:
The current user is Alex and their score is 100 New score: 150
In this example, we are creating a function that increments the score by 50.