PHP Interview Questions & Answers

Showing 10 of 109 questions | Page 6

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.

Web developers should complement their PHP skills with MySQL database  knowledge and JavaScript programming for full-stack development 

Showing 10 of 109 questions

51. How can we know the number of days between two given dates using MySQL?

Use DATEDIFF() SELECT DATEDIFF(NOW(),2006-07-01′);

52. How can we change the name of a column of a table?

This will change the name of column: ALTER TABLE table_name CHANGE old_colm_name new_colm_name

53. How can we change the data type of a column of a table?

This will change the data type of a column: ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type]

54. How can we know that a session is started or not?

A session starts by session_start() function. This session_start() is always declared in header portion. it always declares first. then we write session_register().

55. If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?

Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser.

56. What are the MySQL database files stored in system ?

Data is stored in name.myd Table structure is stored in name.frm Index is stored in name.myi

57. What is the difference between PHP4 and PHP5?

PHP4 cannot support oops concepts and Zend engine 1 is used. PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and SQLLite will is increased in PHP5.

58. Can we use include(abc.PHP) two times in a PHP page makeit.PHP”?

Yes we can include that many times we want, but here are some things to make sure of: (including abc.PHP, the file names are case-sensitive) there shouldnt be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php

59. How can we encrypt and decrypt a data presented in a table using MySQL?

You can use functions: AES_ENCRYPT() and AES_DECRYPT() like: AES_ENCRYPT(str, key_str) AES_DECRYPT(crypt_str, key_str)

60. How can I retrieve values from one database server and store them in other database server using PHP?

For this purpose, you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database.
Questions and Answers for Competitive Exams Various Entrance Test