What is the purpose of the function in the PHP code snippet?
The purpose of the function in the PHP code snippet is to calculate the sum of two numbers passed as arguments. To solve this, we need to define a function that takes two parameters, adds them together, and returns the result.
function calculateSum($num1, $num2) {
$sum = $num1 + $num2;
return $sum;
}
// Example usage
$number1 = 5;
$number2 = 10;
echo calculateSum($number1, $number2); // Output: 15