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


Please Help Members By Posting Answers For Below Questions

How to get elements in reverse order of an array in php?

779


"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.

1750


What are PHP Magic Methods/Functions. List them.

783


Can we run php on tomcat server?

800


How to retrieve values out of an array?

743


Tell me how the result set of mysql be handled in php?

735


What is super keyword in php?

758


What is the use of limit in mysql?

731


Explain php parameterized functions.

766


Explain what is the main difference between require() and require_once()?

765


Which function is used to read a file removing the html and php tags in it upwork?

720


What is session php?

717


Is php a programming language?

795


What is the main difference between php 4 and php 5?

756


What does isset() function?

746