PHP Developer Interview Questions
Hire experienced PHP developers or commision us to build specialized team that delivers exactly to your needs.
It is almost certain that during your PHP developer career, you have interviewed quite a lot. Also we may agree that it is not so simple to prepare for it. We at Kurzor have had plenty of candidates and interviews and collected numerous questions during the last few years. Questions are split into 3 categories according to seniority level. Although we don’t quite like the categorization, it is common to divide developers into those 3 categories so you can check where you are.
During interview in Kurzor our demands are high and you will hear some questions for the first time. This is mainly because we interviewed various candidates also for our PHP outsourcing service
Read Interview Questions for:
Junior level PHP Developers
Those are entry-level programmer questions which almost every developer in PHP needs to answer quickly after more than 1 year of experience.
Question: What does a special set of tags
<?=$variable ?> do in PHP?
Answer: It will output the content of variable into document.
Question: Will comparison of string "10" and integer 11 work in PHP?
Answer: Yes, it will, because PHP is not a typed language and it will try to convert variable types before comparison.
Question: What do you call the constructor of a parent class?
Answer: Just simply by
parent::constructor() in an inherited class constructor.
Question: In PHP what is the difference between a Class and an Interface?
Answer: Interface defines the methods and their parameters. Class can then implement the interface (or multiple interfaces) and needs to define such methods. So interface defines outline and class-specific behaviour.
Question: In a PHP class, what are the three visibility keywords of a property or method?
Answer: public, private, protected
Question: What is Polymorphism?
Answer: It is the basic principle of OOP. You can define base class (may be abstract) Animals and it can then be extended by other classes like Dog, Cat and take part of the behaviour from the parent class.
Question: What’s the full form of PHP
Answer: Original form is Personal Home Page. However, according to the PHP manual, it is PHP: Hypertext Preprocessor.
Question: Rasmus Lerdorf
Answer: The father of PHP.
Question: What Is a Persistent Cookie?
Answer: The type of cookie which is stored permanently on the browser. A persistent cookie can be used for tracking long-term information.
Question: Can you use
include ("abc.php") two or more times?
Answer: Yes, you can include it multiple times like this.
Question: What is the difference between the functions
Unlink() deletes the given file from the file system. Where
unset() makes a variable undefined from memory.
Question: How can we get the browser properties using PHP?
Answer: Simple answer is using
$_SERVER['HTTP_USER_AGENT']. Not so simple is that we need to take into account proxy servers and other situations. In total, this information is defined in 3
Question: How do you create a persistent cookie in php?
Answer: Cookies will only persist for the time you define. To do it for 1 year you can simply do:
setcookie( "cookieName", 'cookieValue', strtotime( '+1 year' ) ); //set for 1 year
Question: What do you mean by having PHP as whitespace insensitive?
Answer: PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.
Question: What are the popular Content Management Systems (CMS) in PHP?
Answer: Systems like WordPress, Joomla, Magento, Drupal etc.
Question: What are the popular frameworks in PHP?
Answer: Most popular are: CakePHP, CodeIgniter, Yii 2, Symfony, Zend Framework etc.
Question: Explain the different types of errors in PHP.
Answer: Those are Notices, Warnings and Fatal errors are the types of errors in PHP. Notices represents non-critical errors. Warnings are more serious errors but they do not result in script termination. Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.
Mid-level PHP Developers
At this level it is common the programmer knows how to answer more complex PHP questions, deeply understands basic operators and constructions. Also has more advanced analytical skills and is able to work without senior programmer supervision.
Question: I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
Answer: If there is a zero at the beginning of the number it says that it is defined by octal value.
Question: What is output of following?
$a = 012; echo $a / 4;
Answer: Value is 2.5 as variable
$a contains an octal number.
Question: Can you send an Ajax request to another domain?
Answer: It is not possible to send an Ajax request if the protocol or host are different. This is called CORS and is checked by the browser.
Question: Does PHP support multiple inheritance?
Answer: No. But class can implement multiple interfaces. Multiple inheritance is partially possible using traits.
Question: What is the difference between
$$var sets the value of
$var as a variable.
Question: Are objects in PHP 5+ passed by value or reference?
Answer: This is a tricky question. To understand it, you need to understand how objects are instantiated.
Question: What is Memcache?
Answer: Technology that caches objects in memory and the application can get to them really fast. It is the basis in scaling larger PHP application.
print() are functions in PHP, both output strings. Function
echo() can take multiple expressions whereas
print() cannot. Moreover
print() returns true or false based on success or failure whereas
Question: Explain the PHP
Answer: The PHP
split() function splits the string into an array by regular expression.
Question: Describe the differences in comparison of variable values
Answer: PHP defined 2 types of comparison:
===. Guess yourself what will be the result of each line:
var_dump(1 == TRUE); var_dump(1.0 == TRUE); var_dump(1 === TRUE);
Kata for PHP Masters
Here are some more complicated questions for a programmer with really good knowledge of PHP. Just have in mind that if you are a senior programmer, it is not all about your PHP skills. The interviewer will also ask about analytical skills, team leadership, which are very important here. As we want to make it harder, try to solve it yourself.
Question: What does
break 2 /
continue 2 do?
Question: Define what is null coalescing operator
?? which is available in PHP 7.0 and later
Question: Describe what is the main problem in comparison of floating point numbers
Question: Explain the starship operator and why it returns the given output
echo 1.5 <=> 2.5; // -1 echo "a" <=> "a"; // 0 echo [1, 2, 3] <=> [1, 2, 4]; // -1
Question: What is the output of the lines below and why:
var_dump(1 << 2); var_dump(8 >> 1 == 9 >> 1);
Question: What is the value of variable
$x and why?
$x = 3 + “15abc” + 012
Do you need help with web programming using PHP? In Kurzor we are really PHP experts and we will help you.