Wednesday, 24 December 2014

Hello Everyone...!!!

As a Web Development Company we know What a company need from a PHP developer. On the basis of that i am here with some Common PHP interview questions which will help you to inhance your skills and prepare you for interviews.

PHP Interview Questions :

Que.1 What is Object Oriented Programming? 

This is usually a pretty open ended question. You should understand classes (objects are instantiated classes), abstract classes, interfaces, methods, properties,inheritance, multiple inheritance as well as why OOP is helpful as compared to procedural programming. 

Que.2 What's the difference between include and require? 

If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

Que.3 What is MVC?

Most programmers know this, but interviewers will likely look for a deep understanding of MVC, and some explanation or examples on how/why/ when you used it.

MVC- Model, View, Controller - is simply a way of organizing your code into 3 separate layers each with there own job.

Model - Usually contains data access code and all of you business logic code.
View - Contains markup/design code, generally html,xml, json.
Controller - Usually contains very little code, just whatever is needed to call the Model code and render the View code.

Que.4 What is the difference between $_GET and $_POST

This is a great question because an interviewer can tell how deeply you understand HTTP and the request/response. If you don't have good understanding of HTTP protocol, google around and get a grasp on it.  

Good answer

Explain the HTTP protocol and how every request contains a method, generally(GET,POST,PUT,DELETE) and what each method signifies.  

Bad answer

$_GET stores variables passed in url as query strings. $_POST stores variables past from using method = $_POST

Que.5 What is the difference between Session and Cookie? 

The main difference between sessions and cookies is that sessions are stored on the server, and cookies are stored on the user’s computers in the text file format. Cookies can not hold multiple variables,But Session can hold multiple variables.We can set expiry for a cookie,The session only remains active as long as the browser is open.Users do not have access to the data you stored in Session,Since it is stored in the server.Session is mainly used for login/logout purpose while cookies using for user activity tracking

Que.6 In a PHP class what are the three visibility keywords of a property or method?

public, private and protected. The default is public.

Public -> Any class may instantiate the class and call the method or property. Protected -> Only the class itself or inherited (children) classes may call a method or property.
Private -> Only the class itself may call a method or property.

Que.7 What is Polymorphism?

Don't get scared by the big word. It's simply the idea that one object can can take on many forms. So in PHP OOP one class "cars" may have two classes that extend it, for example a "Honda" class and a "BMW" class.

Que.8 How to set cookies in PHP? 

Setcookie("sample", "ram", time()+3600);

Que.9 What is the Scope Resolution Operator?

"::" double colons is the scope operator it is used to call methods of a class that has not been instantiated. You should also understand static methods and how they differ from regular methods.

Que.10 How to create a mysql connection? 


Que.11 How to select a database? 


Que.12 How to execute an sql query? How to fetch its result ? 

$my_qry = mysql_query("SELECT * FROM `users` WHERE `u_id`='1'; ");
$result = mysql_fetch_array($my_qry);
echo $result['First_name'];

Share your experience with us .... in Comments.


Post a Comment

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube