PHP Interview Questions and Answers for Freshers 2019

Q1. What is PHP?
PHP is a server-side scripting language. It is the most widely used web technology to create dynamic web pages. There are many PHP based frameworks and Open sources available for free to use. Some examples include WordPress, Drupal, Laravel, etc. We can embed PHP with HTML and can further write server-side code with PHP for web development.
Q2. Which is the latest version of PHP?
Stable release‎: ‎7.1.4 / 13 Apr 2017;
Q3. What are the extensions of PHP File?
.php, .phtml, .php3, .php4, .php5, .php7, .phps .
Q4. What is the difference between include(), include_once() and require_once()
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 except upon failure it will generate a fatal error and halt the script whereas include() will just give a warning and allow the script to continue. require_once() will check if the file already has been included and if so it will not include the file again.
Q5. Differences between GET, POST and REQUEST methods?
GET and POST are used to send information from client browser to web server. In case of GET, the information is sent via the 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 both $_GET, $_POST and $_COOKIE.
Q6. Explain how PHP sends output to Browser? OR How a file is processed when it sends output to the browser?Open website http://www.tutorialmines.netRequest sent to a server of http://www.tutorialmines.netCall PHP Files.PHP Scripts are loaded into memory and compiled into Zend opcode.These opcodes are executed and the HTML generated.The same HTML is sent back to Browser.
Q7. What are the different errors in PHP?
There are 4 basic types of error.
Parse Error – Commonly caused due to syntax mistakes in codes e.g. missing semicolon, mismatch brackets.
Fatal Error – These are basically run time errors which are caused when you try to access what can’t be done. E.g. 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 occur 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.
Q8. What are the various methods/ways to pass data from one web page to another web page?
The different ways to pass the data as follows:SessionCookieDatabaseURL parameters
Q9. What is session and why do we use it?
The session is a superglobal variable that preserves data across subsequent pages. Session uniquely defines each user with a session ID, so it helps to make a customized web application where user tracking is needed.
Q10. What is a cookie and why do we use it?
A cookie is a small piece of information stored in a client browser. It is a technique used to identify a user using the information stored in their browser (if already visited that website). Using PHP we can both set and get COOKIE.

Leave a Reply