Advertisements
Advertisements
Question
Discuss in detail about User define Functions with a suitable example.
Answer in Brief
Advertisements
Solution
- User-Defined Function (UDF) in PHP gives a privilege to user to write own specific operation inside of existing program module.
- Two important steps the Programmer has to create for users define Functions are:
Function Declaration
- A user-defined function declaration begins with the keyword “function”.
- User can write any custom logic inside the function block.
Syntax:
function functionName()
{
Custom Logic code to be executed;
}
Function Calling:
- A function declaration part will be executed by a ! call to the function.
- A programmer has to create Function Calling part j inside the respective program.
Syntax:
functionName();
Example:
<?php
function insertMsg() {
echo “Student Details Inserted Successfully!”;
}
insertMsg(); // call the function
?>shaalaa.com
Is there an error in this question or solution?
