Top Most PHP Interview Questions and Answers

Question 1: What is the current version of PHP?
The latest stable version of PHP is 7.0.5 released at 31 March 2016 .
Question 2: What is PHP?
PHP is an open source server side scripting language used to develop dynamic websites . PHP stands for Hypertext Preprocessor , also stood for Personal Home Page . Now the implementations of PHP is produced by The PHP group .It was created by Rasmus lerdorf in 1995 . It is a free software released under the PHP license .
Question 3: Who is the father of PHP?
Rasmus Lerdorf known as the father of PHP . Php was created by Rasmus Lerdorf In 1995 .
Question 4: What is the current version of Apache?
The latest stable version of Apache is 2.4.20, released on 11th april 2016.
Question 5: What is the current version of MySQL?
The latest stable version of MySQL is 5.5, released on 2016-05-03.
Question 6: Which programming language does PHP resemble to?
PHP syntax resembles Perl and C
Question 7: What does PEAR stands for?
PEAR means “PHP Extension and Application Repository”. it extends PHP and provides a higher level of programming for web developers.
Question 8: How do you execute a PHP script from the command line?
Just use the PHP command line interface (CLI) and specify the file name of the script to be executed as follows:
Question 9: How to run the interactive PHP shell from the command line interface?
Just use the PHP CLI program with the option -a as follows:
Question 10: What is the main difference between PHP 4 and PHP 5?
PHP 5 presents many additional Object Oriented Programming (OPPS) features.
Question 11: Is multiple inheritance supported in PHP?
PHP includes only single inheritance, it means that a class can be extended from only one single class using the keyword ‘extended’.
Question 12: What type of operation is needed when passing values through a form or an URL?
If we would like to pass values through a form or an URL then we need to encode and to decode them using htmlspecialchars() and urlencode().
Question 13: What is the difference between Sessions and Cookies in PHP?
The main difference between a session and a cookie is that session data is stored on the server, whereas cookies store data in the visitor’s browser. There are some difference between session and cookies thath are as following-
  • Session are temporary and Cookies are permanent.
  • Session data is store on server while Cookies are store on user’s computer.
  • Cookies contents can be easily modify but to modify Session contents is very hard.
  • Cookies could be save for future reference but Session couldn’t when user close the browser Session data also lost.
Question 14: What is difference between unset and unlink.
Unset is a function for variable management. Unset is used to destroy a variable in PHP and unlink is a function for file system handling, unlink is used to delete files.
Question 15: How is the ternary conditional operator used in PHP?
It is composed of three expressions: a condition, and two operands describing what instruction should be performed when the specified condition is true or false as follows:
expression1 ? expression2 : expression3;