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
How to get elements in reverse order of an array in php?
"mysql_fetch_row — Get a result row as an enumerated array",this sentence comes from the PHP offical manual.However ,i can not understand the words "enumerated array".I need some help.Thanks a lot to everyone that reply.
What are PHP Magic Methods/Functions. List them.
Can we run php on tomcat server?
How to retrieve values out of an array?
Tell me how the result set of mysql be handled in php?
What is super keyword in php?
What is the use of limit in mysql?
Explain php parameterized functions.
Explain what is the main difference between require() and require_once()?
Which function is used to read a file removing the html and php tags in it upwork?
What is session php?
Is php a programming language?
What is the main difference between php 4 and php 5?
What does isset() function?