In Computer programming some time a specific piece of work done more then one time at different places when you need. For this purpose we use Function. A function is block of statements which are written as separate from the other code and execute when we need it by calling this function. You can use these function over and over when you need it.
In PHP first of all the function is declare with keyword Function. After the keyword Function we write The Function name. Every function must have a unique name and then each function have a body with some statement. body start with { and end with }. The actual statements of function written in between these curly brackets.
Now we take a n simple example to understand the function.
If you want to display the Title of you webpage many time between your other contents then you can do with the help of function.
The code below is practical example of above task
function display_title() { echo "This is LearningHints.com"; } Calling a function in PHP Now You can use this function when ever you need in your page by calling this function. echo "this is simple code" ."
"; display_title( ); echo "this is simple code" ."
"; echo "this is simple code" ."
"; display_title( );
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function