<?php
// Declare a function
function addNumbers($num1, $num2) {
$sum = $num1 + $num2;
return $sum;
}
// Call the function
$result = addNumbers(5, 10);
// Print the result
echo "The sum of 5 and 10 is: $result";
?>
The sum of 5 and 10 is: 15
addNumbers
` that takes two parameters `$num1
` and `$num2
`. Inside the function, we calculate the sum of the two numbers and return it using the `return
` statement. 5
` and `10
` and assign the result to the variable `$result
`. Finally, we print out the result using the `echo
` statement.