<?php
#Syntax:
function functionName() {
code to be executed;
}
function Greetings() {
echo "Hello, welcome!";
}
Greetings(); #Execute function
#Function arguements
#Function arguements are just like prefixes/suffixes and can have multiple arguements
function Polygon(str $prefix = penta, str $suffix = gon) {
echo "$prefix$suffix"
}
Polygon("tetra", "gon");
Polygon(); #Here, we use default value
Polygon("hexa", "gon");
Polygon("septa", "gon");
?>
// functions require 'function' keyword
// separate the parameters with a comma
function addFunction($num1, $num2) {
$sum = $num1 + $num2;
echo "Sum of the two numbers is : $sum";
}
addFunction(1, 2); // echoes: Sum of the two numbers is : 3