So you are done with the first rounds of the selection processes and there is a call letter waiting for the personal interview it is always scary, especially for a fresher to go on that first interview.
So, good preparation for the day is necessary. As a PHP fresher, the one thing that you have as an advantage is the fresh memory of all that textbook definitions of all PHP technical interview questions that the interviewers are going to ask.
It is the personal interview questions for freshers, that will need most of the preparations since these are going to let the interviewers know more about you as an individual and if you will fit in with the company’s values and vision. Here are, therefore, the interview questions in PHP for freshers.
45 Important PHP Interview Questions and Answers for Freshers:
These are textbook interview questions on PHP i.e your educational background. The answers to these PHP questions will be the definitions and can be found in any of the books that were part of your education.
These interview questions for fresher in PHP will be broken down only according to the most common interview questions on PHP for freshers that interviewers will ask in their PHP personal interviews.
1. What is PHP?
It is an open source server side scripting language that is used to develop and create a web page. Also a recursive acronym for PHP: Hypertext Preprocessor can even be used for session tracking and build entire e-commerce sites.
2. Explain Open Source Software?
Open Source Software is a software where the source codes can be used, modified and shared freely by anyone and can also be distributed under the open source definition licenses.
3. What are the uses of PHP?
System functions, handle forms like gathering and saving data to and from a file, send and return data to the user, add, delete, modify data within the database, access cookies, restrict users’ access and encrypting data.
4. What does PEAR stands for and define its uses
PEAR is PHP Extension and Application Repository and it is used to extend PHP to provide a higher level of programming for web developers.
5. Explain the difference between include(), include_once(), require() and require_once()
Where include() function includes and evaluates a specific line, require() can do the exact same function, it will also generate a fatal error and stops the script; require() and require_once() functions the same way whereas require_once() is a way to check if files have been included or not, so that the same function is not repeated twice before executing it.
6. How to display information on a variable that can be readable by a human with PHP?
7. List the different errors in PHP?
There are 4 types of errors in PHP – parse, fatal, warning and notice errors. While parse error is caused due to syntax mistakes in codes, a fatal error is runtime errors caused when trying to access something inaccessible.
Warning error will happen when trying to include a file or delete files that are absent and notice error happens when trying to use a variable that has not been declared.
8. How do you embed PHP code in an HTML page?
The markup tags that can embed php code in an HTML page are
<?php PHP code ?>
<?php PHP code ?>
<script language=”php”> PHP code </script>
9. Displaying text with a php script?
<!–?php echo “Method 1”; print “Method 2”; ?–>
10. Explain session and its uses
A global variable that preserve data in subsequent pages, session is used in making customized web application when the user tracking is needed.
11. How is output directly displayed to the browser?
The uses of special tags such as <?= and ?> for the output are displayed directly on the browser.
12. Explain the purpose of php.ini file
This configuration file is a way to affect PHP’s functionality.
13. Differentiate the final class from a final method?
The final class is that a specific class could not extend whereas a final method functions as a way to stop overriding.
14. Explain what a cookie is and list down its uses.
A cookie is a piece of information that store in the browser and a technique used to identify a user that is using the information that store in their browser
15. How can we print the current date and time?
<?php echo date(‘Y-m-d H:i:s’); ?>
16. What operations can pass values through a form or a URL?
To pass values through a form or URL operations either encoded or decoded using htmlspecialchars() and urlencode().
17. What is PHP as whitespace insensitive?
Whitespace is the elements that typed which invisible on the screen like space and or tabs and when PHP is whitespace insensitive, it means that it will not matter in PHP if whitespace is present because a whitespace character is the same as the visible characters on the screen such as letters and images.
18. What is the difference between the functions unset() and unlink()?
Both functions use to destroy elements and while unset() destroy variables, unlink() destroys a file.
20. How does PHP 5 compare objects?
The operator ‘==’ uses by PHP 5 to compare if two objects instance from the same class and if they have the same attributes and equal values and ‘==’ uses to compare if two objects refer to the same instance of the same class.
21. Explain ‘imagetypes()’
imagetypes() use to define the image format and type which supported by GD-PHP.
22. List the rules that need to name a PHP variable.
The first rule is to always start the name of the variable with a letter or the character ‘_’ and the name of the variable should not use characters other than letters, numbers and the underscore.
23. Define NULL.
NULL is a special constant that has only one value and very case insensitive. It used to evaluate FALSE in Boolean and returns the same when tested with the function IsSet() function.
24. How can the text be displayed with a PHP script?
Text can displayed with a PHP script by using <?–?php echo “Method 1”; print “Method 2”; ?–>
25. What is _LINE_ constant?
This constant is the current line number of the file
26. How do we find the length of the string and the length of the array?
strlen() used to find the length of string and the function count() used for the length of an array.
27. What does ‘Parse error in PHP – unexpected T_variable at line x’ mean?
This is a PHP syntax error that points out that a mistake made at line x has stop parsing and the execution of the program.
28. What is mysql_pconnect()?
This function uses to ensure that there is a persistent connection to the database where the connection will not close when the PHP script ends.
29. What Is AJAX?
30. What is numeric, associate and Multidimensional array?
An array that has a numeric index and where values stored or accessed linearly called a numeric array while an associate array has strings as an index with element values store in association with key values.
A multidimensional array contains one or more arrays and values that can be accessed using multiple indices.
31. How does data sent through URL accessed with the POST method?
When data send through URL, it can access the post method with the $_POST array. However, when a form field has ‘var’ and submitted, it can only be accessed by using the array $_POST[“var”];.
32. Explain the Multidimensional array.
The array that contains one or more values and arrays accessed by the usage of multiple indices calls a Multidimensional array.
33. What is ereg()?
The function that searches strings that specify by string for a pattern specify string and shows the result of true if the pattern found and shows a result that writes false if the pattern not found call an ereg() function.
34. What is getdate()?
getdate() function operates the acceptance of a timestamp by returning an associate array which contains information about the date. It works with the current stamp if the timestamp omitted.
35. Discuss the function of the variable $_PHP_SELF in PHP.
This is a string that contains a PHP script file name.
36. How an XML document parsed in PHP?
PHP gives XML document structured access by altering the document into an object and with the new SimpleXML module PHP 5 makes parsing easy. With this process, a SimpleXML object returned.
37. Explain the process of the MySql database in PHP?
First, PHP creates a MySQL database by using the function mysql_query and using the functions TRUE and FALSE on success and failure respectively.
To open this database connection, PHP uses the function mysql_connect and uses mysql_close to close the database. Throughout the process, PHP uses TRUE and FALSE parameters to determine progress.
38. List the uses of $GLOBALS and $_SESSION variables in PHP?
The variable that contains a reference to every available variable in the script’s scope is the purpose of using the $GLOBALS variable while $_SERVER is the array that holds information in PHP.
39. Define the $_PHP_SELF variable.
The $_PHP_SELF variable is a PHP containing a string filename.
40. What is the purpose of the variable $_FILES[‘file’][‘error’]?
This is the access code when an error occurs that associated with the uploading of files in PHP.
41. Explain the process of sending an email in PHP.
PHP sends an email by the function of the variable mail() which runs with the specification of the receiver’s email address, the email subject, and the actual email.
42. Explain an HTTP request?
The protocol that use to communicate on the web during a web-page visit called an HTTP and an HTTP request a protocol that the browser follows during this web-page visit.
43. List the uses of special tags in PHP.
Special tags in PHP used to directly display output on the browser.
44. What is unlink and unset?
These are a function that helps in the deletion of files from the system, which is the unlink() function whereas the function that helps in making a variable to undefined call an unset().
45. Explain destroying cookies in PHP?
In PHP, cookies destroy by the use of the function setcookie(name, value, expire, path, domain). A good example of using this function is setcookies(“user”,””,time()-3600).
It is always scary as a fresher to go in for an interview and face a panel of experienced corporate giants or just the job that you have always wanted. Being ready with the answers is probably the best way to start with the preparation of the interviews.
The above mentioned are a few latest PHP interview questions and answers for freshers. Confidence is a good trait and a sure way to grab the attention of the hiring panels; honesty is also the best way to answer your questions because one way or another, they are going to know if you are just adding fluff to the answers. PHP
When you prepare, then there should not be any need to be scared or worried about the interview.