Priti's Technical Corner

June 28, 2011

PHP Interview Questions

Filed under: PHP — Tags: , , — pritisolanki @ 12:31 pm

Preetam Chari contribute her experience as follow:

Question1] What is the difference between an abstract class and an interface? Give a real time example when you will an abstract class over an interface?

Question 2] What is the use of final keyword?

Question 3] Explain function overloading and function overriding with an example?

Question 4] Explain the type of inheritance supported by  PHP?

Question 5] Explain different access specifiers in PHP with examples?

Question 6] Is there any difference between exit() and die() in PHP?

Question 7] How do you set a cookie in php?Explain the different parameters?

Question 8] Where does cookie get stored?

Question 9] Where does session get stored?

Question 10]What is the difference between session and cookies?

Please share the answer if you know.



  1. Good questions…. these are some of the common questions asked in many php interviews.

    I can answer the second question.

    The final keyword is used to indicate that a method cannot be overridden and the value of a final variable cannot be changed.

    Comment by dskanth — July 2, 2011 @ 4:38 pm

  2. My answers to some of the above questions:

    4. php only supports single inheritance.
    5. public, private, protected.
    6. exit and die are almost similar, but using die(), we can specify a custom error message.
    7. setcookie(name, value);
    8. browser side
    9. server side
    10. sessions will expire only when we manually delete them, but a cookie can expire when the browser is closed.

    Comment by dskanth — July 2, 2011 @ 4:42 pm

  3. sorry, my answer to the eighth question is “browser side”… it is not shown correctly in my previous answer…

    Comment by dskanth — July 2, 2011 @ 4:43 pm

  4. Answer 4: Single inheritance and Multi-level

    Comment by pritisolanki — July 4, 2011 @ 11:32 am

  5. @pritisolanki How does php support multi level inheritance?
    I am sure that php does not support multiple inheritance.. but what is the multi-level inheritance in php ?

    Comment by dskanth — July 4, 2011 @ 11:36 am

  6. Multi level inheritance is as follow

    class A { // parent class}
    class B extends class A {//child class}
    class C extends class B{//sub child }

    Also we know that we can’t extend multiple class to one class i.e. multiple inheritance is not supported in PHP.


    Comment by pritisolanki — July 6, 2011 @ 12:46 pm

  7. its mean class C can access the B and A both classes .

    Comment by sumit — July 18, 2011 @ 7:47 am

  8. as per the access modifier defined in the classes

    Comment by pritisolanki — July 25, 2011 @ 1:27 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: