<?php
// Declare a function
function square($num) {
return $num * $num;
}
// Call the function
$result = square(5);
// Print the result
echo "The square of 5 is: $result";
?>
The square of 5 is: 25
square
` that takes one parameter `$num
`. Inside the function, we calculate the square of the number using the multiplication operator and return it using the `return
` statement. We then call the function with argument `5
` and assign the result to the variable `$result
`. echo
` statement.