Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

PHP Interview Questions and Answers for Freshers

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, a good preparation for the day is necessary. As a fresher, the one thing that you have as an advantage is the fresh memory of all that textbook definitions of all technical questions that the interviewers are going to ask. It is the personal questions 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 questions to prepare for php interviews.

45 Important PHP Interview Questions and Answers:

These are textbook questions that is your educational background. The answers to these questions will be the definitions and can be found in any of the books that was part of your education. These questions will be broken down only according to the most common questions that interviewers will ask freshers 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 it 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 in 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 of a variable that can be readable by human with php?
print_r()

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, fatal error are 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 ?> in order for the output is 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 final class from final method?
Final class is that a specific class could not be extended whereas a final method functions as a way to stop overriding.

14. Explain what a cookie is and list down its uses.
Cookie is a piece of information that is stored in the browser and a technique used to identify a user that is using the information that is stored in their browser

15. How can we print current date and time?
<?php echo date(‘Y-m-d H:i:s’); ?>

16. What operations can pass values through a form or an url?
In order to pass values through a form or an url operations are either encoded or decoded using htmlspecialchars() and urlencode().

17. What is php as whitespace insensitive?
Whitespace are the elements that are typed which is 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 screen such as letters and images.

18. What is the difference between the functions unset() and unlink()?
Both functions are used to destroy elements and while unset() destroy variables, unlink() destroys a file.

19. Explain the interaction between php and Javascript.
Even though php and Javascript cannot interact directly, however when variable are exchanged inorder php to generate a Javascript code, it makes it possible for Javascript to send variable to php using a url.

20. How does php 5 compares objects?
The operator ‘==’ is used by php 5 to compare if two objects are instanced from the same class and if they have the same attributes and equal values and ‘==’ is used to compare if two objects refers to the same instance of the same class.

21. Explain ‘imagetypes()’
imagetypes() is used to define the image format and type which is supported by GD-PHP.

22. List the rules that is needed 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 is used to evaluate to FALSE in Boolean and returns the same when tested with the function IsSet() function.

24. How can text be displayed with a php script?
Text can be 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 length of string and the length of array?
strlen() is used to find the length of string and the function count() is used for length of 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 is made at the line x has stopped parsing and the execution of the program.

28. What is mysql_pconnect()?
This function is used 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?
Asynchronous JavaScript and XML or AJAX is a technique that will allow updating elements of a web page without reloading the whole page and data is exchanged asynchronously in small amounts of data with the server.

30. What is numeric, associate and Multidimensional array?
An array that has a numeric index and where values are stored or accessed linearly is called a numeric array while an associate array has strings as index with element values stored 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 POST method?
When data is sent through url, it can be accessed with 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 Multidimensional array.
The array that contains one or more values and arrays that is accessed by the usage of multiple indices is called Multidimensional array.

33. What is ereg()?
The function that searches strings that is specified by string for a pattern specified string and shows the result of true if the pattern is found and shows a result that writes false if the pattern is not found is called an ereg() function.

34. What is getdate()?
getdate() function operates the acceptance of a time stamp by returning an associated array which contains information about the date. It works with the current stamp, if the time stamp is 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 is an XML document parsed in php?
php gives XML document a 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 is returned.

37. Explain the process of 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 the TRUE and FALSE parameters to determine the 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 string file name.

40. What is purpose of the variable $_FILES[‘file’][‘error’]?
This is the access code when an error occurs that is 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 is used to communicate in the web during a web-page visit is called an HTTP and an HTTP request is the protocol that the browser follows during this web-page visit.

43. List the uses of special tags in php.
Special tags in php is used to directly display an output on the browser.

44. What is unlink and unset?
These are 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 be undefined is called an unset().

45. Explain destroying cookies in php?
In php, cookies are destroyed 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. 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. When you are prepared, then there should not be any need to be scared or worried about the interview.

The post PHP Interview Questions and Answers for Freshers appeared first on WiseStep.



This post first appeared on WiseStep - Wise Ideas On Careers, Employment, Recr, please read the originial post: here

Share the post

PHP Interview Questions and Answers for Freshers

×

Subscribe to Wisestep - Wise Ideas On Careers, Employment, Recr

Get updates delivered right to your inbox!

Thank you for your subscription

×