what is interface in php? how it is use?
Answer Posted / nur nahid hasan
Interface: Since we all knows that PHP does not support the
multiple inheritance. But don't worry we have an excellent
idea to do the multiple inheritance in php is Interface.
Interface is just like a class using interface keyword and
contains only function declarations(function with no body).
function is defined in the classes where you call it.
Ex:-
interface FirstInterfName{
function Add();
function Sub(10,5);
}
interface SecondInterfName{
function glbfunc1();
function glbfunc2();
}
class ClassName implements FirstInterfName,SecondInterfName
{
fuction Add()
{
$a = 5;
$a = $a + 1;
echo $a;
}
fuction Sub($a,$b)
{
$c = $a -$b;
echo $c;
}
function glbfunc1()
{
Implements here method...............
}
function glbfunc2()
{
Implements here method...............
}
}
| Is This Answer Correct ? | 19 Yes | 6 No |
Post New Answer View All Answers
What is uniqid php?
What is varchar mysql?
Explain me is it possible to destroy a cookie?
What is strstr php?
What are getters and setters and why are they important?
What is member function?
Why do we use php?
Tell me how to strip whitespace (or other characters) from the beginning and end of a string?
What is difference between strstr() and stristr()?
Does apache use php?
What is the output of the ucwords function in this example?
Is php easy language to learn?
Explain what does the unset() function means?
How can you execute php script from the command line?
How do you check if a variable has been set in php?