- 1 Top 10 Questions And Answers for PHP Interview
- 1.0.1 What is PHP?
- 1.0.2 What is Open Source software?
- 1.0.3 What is difference between include(), include_once() and require_once()?
- 1.0.4 What is the difference between GET, POST and REQUEST methods?
- 1.0.5 Which are the different types of PHP?
- 1.0.6 What is the session and why do we use it?
- 1.0.7 What is the cookie and why do we use it?
- 1.0.8 How to print the current date and time?
- 1.0.9 What function do we use to find length of string, and length of array?
- 1.0.10 What is the difference between unset() and unlink() function?
Top 10 Questions And Answers for PHP Interview
What is PHP?
Ans.: PHP is an open source server-side scripting language commonly used in web applications.
What is Open Source software?
Ans.: Software in which the source codes are freely used, modify, and shared by anyone is called Open Source software. These can also be distributed under licenses that adhere with the Open Source Definition.
What is difference between include(), include_once() and require_once()?
Ans.: The include() statement includes and evaluates a specified line i.e. It will include a file based in the given path. require() does the same thing expect upon failure it will generate a fatal error and halt the scrip whereas include() will just gives a warning and allow script to continue. require_once() will check it the file already been included and if so it will not include the file again.
What is the difference between GET, POST and REQUEST methods?
Ans.: GET and POST are used to send information from client browser to web server. In case of GET the information is send via GET method in name/value pair and is URL encoded. The default GET has a limit of 512 characters. The POST method transfers the information via HTTP headers. The POST method does not have any restriction in data size to be sent. POST is used for sending data securely and ASCII and binary type’s data. The $_REQUEST contains the content of bot $_GET, $_POST and $_COOKIE.
Which are the different types of PHP?
Ans.: These are four types of errors.
- Parse Error: Commonly caused due to syntax mistakes in codes. Ex. Missing semicolon, mismatch brackets.
- Fatal Error: These are basically runtime errors which are caused when you try to access what can’t be done. Ex. Accessing a dead object, or trying to use a function that hasn’t been declared.
- Warning Error: These occur when u try to include a file that is not present or delete a file that is not on the server. This will not halt the script; it will give the notice and continue with the next line of the script.
- Notice Error: These errors occurs when u try to use a variable that hasn’t been declared, this will not halt the script, It will give the notice and continue with the next line of the script.
What is the session and why do we use it?
Ans.: Session is a super global variable that preserves data across subsequent pages. Session uniquely defines each user with a session ID, so it helps to make customized web application where user tracking is needed.
Ans.: Cookie is a small piece of information stored in the client browser. It is a technique used to identify a user using the information stored in their browser (it already visited that website). Using PHP we can both set and get COOKIE.
How to print the current date and time?
Echo date(‘Y-m-d H:i:s’);
What function do we use to find length of string, and length of array?
Ans.: For finding the length of string we use strlen() function and for array, we use count() function.
Ans.: unset() is used to destroy a variable whereas unlink() is used to destroy a file.