ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Scripts >> PHP
 
 


 

 
 PHP interview questions  PHP Interview Questions (660)
 ASP interview questions  ASP Interview Questions (252)
 CGI Perl interview questions  CGI Perl Interview Questions (76)
 JavaScript interview questions  JavaScript Interview Questions (176)
 VB Script interview questions  VB Script Interview Questions (343)
 JSP interview questions  JSP Interview Questions (100)
 Shell Script interview questions  Shell Script Interview Questions (158)
 Python interview questions  Python Interview Questions (5)
 Tcl interview questions  Tcl Interview Questions (19)
 Awk interview questions  Awk Interview Questions (6)
 AJAX interview questions  AJAX Interview Questions (24)
 Ruby on Rails interview questions  Ruby on Rails Interview Questions (21)
 Scripts AllOther interview questions  Scripts AllOther Interview Questions (48)
Question
what is interface in php? how it is use?
 Question Submitted By :: PHP
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
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 ?    110 Yes 16 No
Jadhav Yeshwanth
 
Answer
# 2
Interface is a object oriented concept,
It is the place where we can define the function.
When a class use that interface in that class the total
function body part will describe.
after that we can call that function in other class and we
are get result.
 
Is This Answer Correct ?    74 Yes 24 No
Asish Kumar Khuntia(mithu)
 
 
 
Answer
# 3
Interface is a prototype of method body.
when ever we want to develop the application by third party
vendor people, at that time we have to provide only interface.
why because the people gives the implementation in their own
way so we have to provide the interface.
 
Is This Answer Correct ?    28 Yes 8 No
Thirupathi Rao
 
Answer
# 4
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 ?    21 Yes 5 No
Sanjeev Kumar
 
Answer
# 5
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 ?    14 Yes 6 No
Nur Nahid Hasan
 
Answer
# 6
Interface gets useful when you need to extend a class from
more than one parent class since class can not do this.

Why would you want to implement just a single interface on a
class. After all, a class already has everything that an
interface has.
 
Is This Answer Correct ?    13 Yes 7 No
Raju
 
Answer
# 7
interface = multiple inheritance

means:
An interface is a named collection of method definitions, without implementation.

example:
interface interfaceName{
public function func1();
public function func2();
}

//we will use this interface as
class ClassName implements interfaceName
{
//note all interface func's must implement here
}
 
Is This Answer Correct ?    2 Yes 0 No
Sivannarayana
 
Answer
# 8
interface =multiple inheritance

means:
An multiple inheritance is not supported in php that time we
using interface. It is implements two baseclasses but class
extends only one class.
 
Is This Answer Correct ?    2 Yes 0 No
Karthi
 
Answer
# 9
Why you can :

interface FirstInterfName{
function Add();
function Sub(10,5); // this line can u pass 10,5 like this
}
 
Is This Answer Correct ?    2 Yes 6 No
Neakdek
 
Answer
# 10
in english? lol 
Is This Answer Correct ?    12 Yes 55 No
Johan
 

 
 
 
Other PHP Interview Questions
 
  Question Asked @ Answers
 
Is there a way to encrypt text from php?   5
What is meant by urlencode and urldocode?   2
What are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ? HCL 7
How to make multilanguage site in php? (like english,tamil)   2
How can we get the browser properties using PHP?   6
can anyone tel me about the Expression engine Note:Its a CMS in Php   2
Does it possible to compile php with mysql without having mysql sources?   2
explain in brief type juggling in php?   1
What is indexing how many types? Net-Solution 3
please can any one tell is there any openings for freshers in PHP ...please tell the company name and address sir where can i find ..php related companies and how much i expect salary as a fresher in php ..i finished my LAMP course i done my mca ..i seen in many job portals there is no job for freshers in php can any one tel me please in chennai i need php jobs ..? thank u friends   1
What is meant by nl2br()? Rushmore-Consultancy 4
How can we encrypt and decrypt a data present in a mysql table using mysql? Microsoft 3
 
For more PHP Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com