PHP technical interview questions and answers are essential for candidates preparing for web development roles. PHP powers millions of websites and content management systems, so companies often evaluate your knowledge of syntax, arrays, sessions, cookies, form handling, OOP concepts, and database connectivity. Popular companies like TCS, Wipro, Infosys, Capgemini, Cognizant, and Accenture regularly include PHP questions in coding rounds and technical interviews. This guide explains the most frequently asked PHP interview questions with simple examples and clear definitions. Whether you are a fresher preparing for campus placements or an experienced developer, these questions will help you understand PHP concepts better. You can also download PHP interview PDFs and practice mock questions for better preparation.
11. whats the difference between accessing a class method via -> and via ::?
:: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.
12. Are objects passed by value or by reference?
Everything is passed by value.
13. How do you call a constructor for a parent class?
parent::constructor($value)
14. whats the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
15. Why doesnt the following code print the newline properly?
Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.
16. whats PHP
The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.
17. What Is a Session?
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.
There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.
Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
18. What is meant by PEAR in php?
PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install “packages”
19. What does a special set of tags do in PHP?
What does a special set of tags = and ?> do in PHP?
The output is displayed directly to the browser.
20. How do you define a constant?
Via define() directive, like define (”MYCONSTANT”, 100);