adspace


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


Please Help Members By Posting Answers For Below Questions

What does $_files means?

1162


What sized websites have you worked on in the past?

1085


Write a program using while loop?

1115


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

1988


hello all, I need some sample placement papers in lion bridge.. can anyone help me?

2175


What is the difference between htmlentities() and htmlspecialchars()?

1090


Tell me what kind of things have you done on the social side?

1064


What is the current stable version of php?

1123


sort term descripttion form, report and uery

2254


how to detect a mobile device using php

1173


How to calculate the difference between two dates using php?

1143


How can we extract string "pcds.co.in" from a string "https://info@pcds.co.in" using regular expression of php? More on reg can you explain

1077


Explain me is it possible to destroy a cookie?

1026


How to create a web form?

1109


What is trait in php?

1065