Facing Interview for PHP Jobs. PHP is a widely used open-source free Program widely used in the designing and development of a website.
PHP language for designing and development of dynamic websites. A website that can be CMS or dynamic mean you have control to change, update and content of a website.
Facing Php interview questions means that you have knowledge of Data Structure, C, C++, Algorithms and more then it you need to have knowledge of how to create a database, how to put content, how to make reasoning so PHP Interview Can be tough.
So make it easy for you we make a List of PHP interview questions and answers for beginners to experienced that help you in getting a job in a reputed company as a Software Engineer.
Mostly Asked PHP Interview Questions And Answers
Q1. What’s PHP?
Ans. 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.
Q2. What Is a Session?
Ans. 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.
Q3. What is meant by PEAR in PHP?
Ans. 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 organized OOP library. PEAR also provides a command-line interface that can be used to automatically install “package
Q4. What is the difference between $message and $$message?
Ans. $message is a simple variable whereas $$message is a reference variable. Example:
$user = ‘bob’
is equivalent to
$holder = ‘user’;
$$holder = ‘bob’;
Q5. What are the differences between DROP a table and TRUNCATE a table?
Ans. DROP TABLE table_name – This will delete the table and its data.
TRUNCATE TABLE table_name – This will delete the data of the table, but not the table definition.
Q6. How do you call a constructor for a parent class?
Q7. WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
Ans. Here are three basic types of runtime errors in PHP:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although you can change this default behavior.
2. Warnings: These are more serious errors – for example, attempting to include() a file that does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These are critical errors – for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.
Internally, these variations are represented by twelve different error types
Q8. What’s the special meaning of __sleep and __wakeup?
Ans. __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
Q9. How can we submit a form without a submit button?
Q10. What is the functionality of the MD5 function in PHP?
Ans. string md5(string)
It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.
Q11. How can I load data from a text file into a table?
Ans. The MySQL provides a LOAD DATA INFILE command. You can load data from a file. Great tool but you need to make sure that:
a) Data must be delimited
b) Data fields must match table columns correctly
Q12. Who is known as Father of PHP
Ans. Rasmus Lerdorf
Q13. How can we know the number of days between two given dates using MySQL?
Ans. Use DATEDIFF()
Q14. How can we change the name of a column of a table?
Ans. This will change the name of the column:
ALTER TABLE table_name CHANGE old_colm_name new_colm_name
Q15. How can we change the data type of a column of a table?
Ans. This will change the data type of a column:
Try to solve questions yourself.
- 1. What are the differences between getting and post methods in form submitting, give the case where we can use get and we can use post methods?
- 2. Who is the father of PHP and explain the changes in PHP versions?
- 4. How can we submit a form without a submit button?
- 5. In how many ways we can retrieve the data in the result set of MySQL using PHP?
- 6. What is the difference between mysql_fetch_object and mysql_fetch_array?
- 7. What is the difference between $message and $$message?
- 8. How can we extract string ‘techinterviews.com ‘ from a string ‘http://www.techinterviews.com’ using regular expression of PHP?
- 9. How can we create a database using PHP and MySQL?
- 10. What are the differences between require and include, include_once?
- 11. What are the different types of errors in PHP?
- 12. What is the functionality of the function strstr and stristr?
- 13. What are the differences between PHP 3 and PHP 4 and PHP 5?
- 14. How can we convert asp pages to PHP pages?
- 15. What is the functionality of the function htmlentities?
- 16. How can we get the second of the current time using date function?
- 17. How can we convert the time zones using PHP?