Functions
1. A function is a block of statements that perform a specific task of same kind.
2. A function has a name and it is reusable.
3. A function invoked from other parts of a program.
4. A function may have return value or not.
5. A function may have parameters or not.
6. The statements inside the function will not be executed automatically.
7. The function is called from any part of the program and then execute the statements inside the function.
2. A function has a name and it is reusable.
3. A function invoked from other parts of a program.
4. A function may have return value or not.
5. A function may have parameters or not.
6. The statements inside the function will not be executed automatically.
7. The function is called from any part of the program and then execute the statements inside the function.
Syntax
function name(){
// statements that will be executed
}
Example: 1
<?phpfunction test()
{
echo "I am inside function test()";
}
echo "After this line, function test() will call.<br> ";
test();
?>
Output
After this line, function test() will call.I am inside function test()
Example: 2
<?phpfunction test1()
{
echo "<br>I am inside function test()";
}
echo "After this line, function test() will call.";
test1();
echo "<br />"."Again function test() will call, after this line. ";
test1();
?>
Output
After this line, function test() will call.I am inside function test()
Again function test() will call, after this line.
I am inside function test()
No comments:
Post a Comment