The real power of PHP comes from its functions. A function is a block of statements that can be used repeatedly in a program. It will not execute automatically when a page loads; it must be called by the script.
A user-defined function declaration starts with the word function, followed by the name you give to that function.
<?php
function writeMsg() {
echo "Hello, welcome to RedoHub!";
}
?>
To call the function, just write its name followed by parentheses (). You can call the same function multiple times wherever needed.
<?php
function writeMsg() {
echo "Hello, welcome to RedoHub!";
}
writeMsg(); // Call the function
?>
writeMessage()).
calculateTotal() instead of func1()).