what is interface in php? how it is use?
Answer Posted / sanjeev kumar
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 ? | 24 Yes | 7 No |
Post New Answer View All Answers
How to execute an sql query? How to fetch its result?
Tell me how can we change the maximum size of the files to be uploaded?
Is php class name case sensitive?
How to return a value back to the function caller?
Explain PHP?
What is the purpose of the php empty function?
What is php routing?
Is empty array php?
List some array functions in php?
What is php and sql?
What does isset() function?
What is a PHP accelerator?
How can you retrieve a cookie value?
What is the best php version for wordpress?
What is different between software and app