Creating a Function
Creating your own function is easy; just start with the keyword function followed by the function name and parenthesis. After that place your code between two curly braces { and } called the opening and closing braces, respectively. Now you can use the function as many times as you need it. This saves you the trouble of having to re-type the code every time.
The code below demonstrates a function that outputs a message to the screen
<?php
functionechoMessage() {
echo “Hello, I am a PHP function!”;
}
echoMessage();
?>
Output:
Hello, I am a PHP function!