Skip to content

PHP interview questions and answers for web developers

This article is supposed to present you some PHP interview questions and answer that you can find below. Here are some general questions, PHP questions for interview, SQL questions and HTTP questions.

General Questions

  1. What version control systems have you used (Git, SVN etc.)?
  2. How do you go about testing your PHP?
  3. How do you choose a library / module / package ?
    Hint: Do you take a look if there’s a documentation ? Do you take a look over its GitHub repository ? Do you take a look of there are issues opened and if there’s some activity ?
  4. How do you solve a blocker ? Let’s say you encounter a problem in the current project and that’s a big blocker and you don’t know where is the problem ? How do you start to solve it ?
  5. What’s the biggest problem faced on your projects and how did you solve it?
  6. How do you organize your code ?
    Hint 1: How do you name your folders ?
    Hint 2: How do you name your files ?
  7. How do you decide to refactor code ?
  8. Do you heard about MVC (Model View Controller) ? What is that ?
  9. Do you prefer to work on a team or alone?
  10. Do you have experience with Linux ? What about Linux Console ?

Technical Questions

PHP

1. Do you know which is the difference between a constant and a variable ?
2. Result of

floor(3.14)

Answer: 3

3. What value is returned from the above statement?

echo join("", array_reverse(str_split("i'm a lasagna hog")));

Answer: “goh angasal a m’i”

4. What is the value of count($array)?

$array = array();

array_push($array, 1);
array_push($array, 2);

Answer: 2

5. What is the result of the two alerts functions?

$foo = "Hello";

function alert_a() {
    global $foo;

    $bar = " World";

    echo ($foo . $bar);
}

function alert_b() {
    $bar = " World";

    echo ($foo . $bar);
}

alert_a();
alert_b();

Answer:
alert_a() = Hello World
alert_b() = E_NOTICE : type 8 — Undefined variable: foo — at line 15 World

SQL

1. How do you choose a column to be indexed?

Answer: You’d like to index columns, that appear in WHERE clause or JOIN condition.

2. Are you familiar with NoSQL databases? Which one ?

Answer: example MongoDB

3. Do you know what is an ORM (Object Relational Mapping) ?

Answer: Technique to convert query results of database into a Object Oriented way.

4. Why do databases treat null as special case? For example, why does SELECT * FROM table WHERE field = null not match records with null field in SQL?

Answer: The correct syntax is where is null

HTTP

1. Can you give me some examples of HTTP methods? And why are used commonly for?

Answer:

  • GET = retrive some data
  • POST = sent data to server
  • PUT = update some data
  • PATCH = update some data partially

2. Common Server Response Codes

2.1. Describe server response code 200.

Answer: (“OK”) Everything went ok. The entity-body, if any, is a representation of some resource.

2.2. Describe server response code 301.

Answer: (“Moved Permanently”) Client triggered an action on the server that caused the URI of a resource to change.

2.3. Describe server response code 404.

Answer: (“Not Found”) Client requested a URI that doesn’t map to any resource.

2.4. Describe server response code 500

Answer: (“Internal Server Error”) A problem occurred on the server side. The entity-body, if any, is a error message.

Published inTips

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *