Introduction to Core PHP Interview Questions and Answers
Core PHP is actually meaning of very basic PHP. It normally used for creating some dynamic web pages for displaying to the end client through their own browser. It has basic core logic of programming in server side and displays in client side based on the expected logic.
Now, if you are looking for a job which is related to Core PHP then you need to prepare for the 2020 Core PHP Interview Questions. It is true that every interview is different as per the different job profiles. Here, we have prepared the important Core PHP Interview Questions and Answers which will help you get success in your interview.
In this 2020 Core PHP Interview Questions article, we shall present 10 most important and frequently asked Core PHP interview questions. These interview questions are divided into two parts are as follows:
Part 1 – Core PHP Interview Questions (Basic)
This first part covers basic Core PHP Interview Questions and Answers.
Q1. Two very common functions used in core PHP for a long time. Those functions are include() and require(). Please give some clear difference in between include and require a function for core PHP?
Include() and require() both are using for include some specific file with the requesting page. The main difference between them is,
If developer use requires for including the file, then somehow process throwing some fatal error during execution for unavailability of the file then execution of the process will entirely stop. But if developer us include for including the file, then the entire process will not stop, it will ignore the fatal error and go for executing the next step without stopping the process.
Q2. Suppose we are willing to get the IP address for some client who is using PHP developed web application. Please explain how we can get that IP information in PHP?
There have several options for fetching IP addresses of the client execution machine in PHP. The developer can able to write some critical script for fetching those data externally. But one of the popular and very basic approaches of fetching IP address is :
Let us move to the next Core PHP Interview Questions.
Q3. Explain in details about the difference between two popular functions of PHP unset() and unlink()?
This is two of the common keywords using by the PHP developer in case of handling file system proper manner. Suppose the developer needs to delete or undefined some of the file already mapped with the request then both of these functions normally used. The main difference in between them is:
If developer used unset() on any file then that file reference is going to be undefined for the entire application, whereas if developer mention one file as unlink, then that file will be removed from the directory and as well as not available for the entire application.
Q4. There are several error types available in PHP. Explain some of the major error types which are very frequently used for PHP application and give the proper difference of them?
This is the common Core PHP Interview Questions asked in an interview. Several responsibilities normally need to follow by a Core PHP tester in the current IT industry. Normally in PHP, we are handling three kinds of errors:
- Notices: This is just given one notice of wrong coding or execution. It is very simple and mostly non-critical error occurred normally script execution time. Suppose application trying to access some undefined variable then this kind of notice will come.
- Warnings: It is again not that much critical error, but still any kind of wrong execution warning will be given without stopping the normal execution of the process. The example is, include function used but some file is missing in the directory, then the warning will be given but the process will execute successfully.
- Fatal: This is one of the most important error came in PHP script execution. It mainly causes termination of the process by given proper explanation. The example is, trying to access some nonexistence object or require file uploading but the file is missing.
Q5. Explain in details about the difference between GET and POST in PHP application?
Some of the key differences between GET and POST in PHP are explaining below:
- GET information always passing through URL, so it is always visible to everyone, whereas POST information is in embedded with the request and sometimes it is in the encoded format, so it will not able understandable or visible to the normal user.
- GET have some restriction on handling request, define characters are 2048. Whereas POST doesn’t have this kind of restriction at all.
- GET only allows require ASCII data, whereas POST does not have this kind of restriction.
- Developer common approach to use Get for fetching data, whereas POST is using for inserting or updating.
Part 2 – Core PHP Interview Questions (Advanced)
Let us now have a look at the advanced Core PHP Interview Questions and Answers.
Q6. Suppose developer needs to enable some of the error reporting utility in PHP. How it can be done, please explain in details?
Displaying error message is one of the key requirement especially in case of debugging the error by the developer, it normally displays the number of lines of the script where fatal error got generated. The developer can display this error in possible page by given below command:
But for initializing or activating of displaying error in PHP application, the developer needs to follow any of the below approach:
- Display_error = ON in php.ini
- Ini_set(‘display_error’, 1) in the specific script file
Q7. Explain in details about Traits in PHP application?
Traits are one of the popular mechanism specifically for the PHP developer. As this mechanism help developer for allowing to create some reusable code again for the PHP language application in case of those objects where inheritance objective not fully supported. In the case of Traits, not possible to inheritance by its own mechanism. It is one of the key requirement that PHP developer should know about the key and powerful feature of the language before starting development in PHP.
Let us move to the next Core PHP Interview Questions.
Q8. Suppose one constant has been defined in one of the PHP scripts. Now developer needs to change that constant value during the execution. Is it possible to do? Explain?
If one value declared as constant in PHP, then it will never be changed by any process during execution. Constant value needs to be assigned at the time of initialization.
Q9. Is it possible to extend one class which are defined as final? Explain?
This is the most popular Core PHP Interview Questions asked in an interview. Some popular test cases in the current IT industry. If the developer defines one class as final, then extending of that class is absolutely not possible. If one class or method declared as final then creating child class and method overloading or overriding both are not possible.
Q10. Explain in details about _destruct() and _construct() methods available in PHP classes?
Every PHP object should have two methods called constructor and destructor. Both the methods are mainly defined in build in. Constructor method normally called immediately after creating one new instance of the specific class, normally used for initializing all the properties of a class. Whereas the destructor methods are mainly using for release the object of the class from the application memory. Destruction method does not require to pass any parameter.
This has been a guide to the list of Core PHP Interview Questions and Answers. Here we have listed the most useful 10 interview sets of questions so that the jobseeker can crack the interview with ease. You may also look at the following articles to learn more –