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

What is php's mysqli extension?

559


Does php have future?

572


How to create a session? How to set a value in session?

515


How can we destroy the cookie in php?

523


How To Get the Uploaded File Information in the Receiving Script?

579






Tell me what is the importance of "action" attribute in a html form?

527


What is the meaning of php?

509


Which is better #define or enum?

522


What is cookies php?

518


List some array functions in php?

502


How can you increase the maximum execution time of a script in php?

513


How to break a file path name into parts?

534


What does odbc do in context with php?

563


What is use of header() function in php?

543


What is default session time and path in PHP. How to change it?

536