PHP Interview Questions
This post is just an attempt to help you guys to know and understand how tricky a PHP interview can be, what type of questions can be asked to you and how effectively you can tackle those questions. I do not guarantee that these will be the questions you will be asked in the interview, it is just an attempt to guide you in your preparations.
So, lets start with the question & answer session.
Question-1. What type of inheritance PHP supports?
Answer: There are different types of inheritance if we talk in terms of Object Oriented Programmin (OOP) world namely Single Inheritance, Multiple Inheritance, Hierarchical Inheritance, Multi-level inheritance, etc. but PHP do not supports the Multiple Inheritance.
Question-2. What is the difference between the functions/methods unlink and unset?
Answer: The answer is very simple:
unlink function deletes a file e.g. unlick(‘file_path/file_name.extension’);
whereas unset functions removes a variable e.g. unset($variable_name);
Question-3. What is PHP?
Answer: PHP (Hypertext Processor) is a scripting language commonly used for web applications. PHP can be easily embedded in HTML. PHP based applications generally runs on a web server. It is opensource and can be used across a variety of servers, operating systems and platforms. It is one of the Pillars of LAMP (Linux Apache MySQL PHP)based development.
Question-4. What is PEAR in php?
Answer: PEAR (PHP Extension and Application Repository) is a framework and repository for reusable PHP components. PEAR is a code repository containing all kinds of php code snippets and libraries.
Question-5. How do you call a constructor for a parent class?
Answer: You can call a constructor of a parent class with the help of following block of code:
parent::constructor();//call to parent constructor without passing any paramter
parent::constructor($value);//call to parent constructor with an parameter
Question-6. What is the difference between a parameter and argument in programming?
Answer: A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method’s parameters. Parameter is variable in the declaration of function. Argument is the actual value of this variable that gets passed to function.
Question-7. How do you get the current logged user in MySQL?
Answer: We can do so by executing the following mysql command using console:
Question-8. What is the default PHP session time?
Answer: The default PHP session time is 1440 seconds.
Question-9. What is the default path for session storage?
Answer: The default storage path for session is /tmp folder.
Question-10. What do you know about MIME?
Answer: MIME is “Multi-purpose Internet Mail Extensions”. It is extension protocol that helps to exchange the different kinds of data files over the internet. These files can be of audio, video, images, application programs and ASCII types etc.
Please keep exploring for part 2.