PHP Custom Programming
What is Function?
Explanation
The authors of PHP extended it into a full-fledged programming language that can be used both for simple as well as for complex object-oriented programming.
Some of the useful features of PHP are its built-in functions. But PHP also allows you to write your own functions. The main advantage of custom functions is reuse. If you don't write functions, you may have to write the same piece of code numerous times in your application, whether it's within the same PHP file or in others.
Syntax:
function functionName()
{
code to be executed;
}
Example :
function write()
{
echo "Sam Anderson";
}
echo "My name is ";
write();
Result:
My name is Sam Anderson
In the above example, the a function is called to print a string.