What is Function?
Function are those callable section of code that you can pass data to, and that can return data to you. Function are subprograms which are used to compute a value or perform a task.
Which are the Importance of Function?
- Easy to debug
- Reusability
- No code repetition
- Easy to handle codes
How to create a Function?
Syntax:-
function function_name( )
{
Block of statement;
}
Example:-
Some rules for creating a function:-
- Function name only starts with a letter, an underscore ( _ ).
- Function name cannot start with a number.
- Do not use Predefined constant name e.g. PHP_VERSION ,PHP_OS etc.
- Do not use reserved keywords. e.g. else, if etc.
- Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.