what is interface in php? how it is use?

Answer Posted / jadhav yeshwanth

An Interface is like a template similar to abstract class
with a difference where it uses only abstract methods.

In simple words, an interface is like a class using
interface keyword and contains only function
declarations(function with no body).

An Interface should be implemented in the class and all the
methods or functions should be overwridden in this class.

for eg:

interface InterfaceName{
function fun1();
function fun2(a,b);
}

class ClassName implements InterfaceName{
fuction fun1(){
function implementation.......
}
fuction fun2(a,b){
function implementation.......
}
}

Is This Answer Correct ?    125 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to get number of elements in an array?

537


How to remove an empty directory?

580


What is the value for this auto incremented field user_pri_id?

506


Explain a resource?

612


What is the current stable version of php? What advance thing in php7?

517






Why do we show php code in browser?

514


How to write comment in php?

694


How to concatenate two strings together in php?

562


Which of the data type is compound datatype supported by PHP?

551


How to move uploaded files to permanent directory?

534


Suppose your zend engine supports the mode Then how can you configure your php zend engine to support Mode ?

575


What is regular expression in php?

537


What is zend studio for?

540


What are the advantages of php mysql?

521


What is the use of curl()?

633