Header Ads

PHP Interview Questions and Answers | for 2 Year Experience/ Freshers


PHP Interview Questions and Answers

PHP is a language to create your own web page. There are many candidates who are looking for jobs in PHP due to its scope. Here we are providing some PHP Interview Questions and Answers for 02 years’ experience and freshers candidates.

Before going for PHP interview, you should read all the basics questions that can be asked in the interview. PHP is very important part to get the Job in web world. Every web developer must have knowledge of PHP language.

Best Interview Questions For PHP:

With PHP interview questions will help you to be web developer. We have given some best PHP interview questions along with answers on this page. You should take time to read it carefully and prepare well.

To know the more PHP Interview Questions and Answers, read this page which is created by team of www.privatejobshub.in.

PHP Interview Questions and Answers

Que-1: Who is the Father of PHP?

Ans. Rasmus Lerdorf

Que-2: What is PHP stands for?

Ans. Hyper text Pre Processor

Que-3: How to include a file to a php page?

Ans. We can include a file using "include() " or "require()" function with file path as its parameter.

Que-4: require_once(), require(), include().What is difference between them?

Ans: require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

Que-5: Differences between GET and POST methods?

Ans: We can send 1024 bytes using GET method but POST method can transfer large amount of data and POST is the secure method than GET method

Que-6: How to declare an array in php?

Ans: Eg : var $arr = array('apple', 'grape', 'lemon');

Que-7: What is use of count() function in php ?

Ans: count() is used to count all elements in an array, or something in an object.

Que-8: How to set cookies in PHP?

Ans: Setcookie ("sample", "ram", time()+3600);

Que- 9: What does PEAR stands for

Ans. PEAR means “PHP Extension and Application Repository”. it extends PHP and provides a higher level of programming for web developers.

Que-10: How to Retrieve a Cookie Value?

Ans: eg : echo $_COOKIE["user"];

Que-11: What Is a Session?

Ans. It can be used to store information on the server for future use.

Que-12: Is variable name case sensitive?

Ans. Yes variable name case sensitive and we cannot start a variable with number like $6name as a valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

Que-13: How we know the total number of elements of Array?

Ans: There are two methods through which we can know the total number of elements:
  • sizeof($array_var)
  • count($array_var)
Que-14: What is the difference between explode() and split() functions?

Ans: Split function splits string into array by regular expression. Explode splits a string into array by string.

Que-15: How to strip whitespace (or other characters) from the beginning and end of a string ?

Ans. The trim() function removes whitespaces or other predefined characters from both sides of a string.

Que-16: How to set a page as a home page in a php based site?

Ans: index.php is the default name of the home page in php based sites.

Que-17: How to find the length of a string?

Ans: strlen() function used to find the length of a string.

Que-18: what is the use of isset() in php?

Ans. This function is used to determine if a variable is set and is not NULL.

Que-19: What is the use of "ksort" in php?

Ans: It is used for sort an array by key in reverse order

Que-20: How to delete a file from the system

Ans: Unlink() deletes the given file from the file system.

Que-21: What’s the difference between the include() and require() functions?

Ans: They both include a specific file but on require the process exits with a fatal error if the file can’t be included, while include statement may still pass and jump to the next step in the execution.

Que.22: How can we get the IP address of the client?

Ans. This question might show you how playful and creative the candidate is because there are many options. $_SERVER["REMOTE_ADDR"]; is the easiest solution, but the candidate can write x line scripts for this question

Que.23: What’s the difference between unset () and unlink()

Ans. Unset () sets a variable to “undefined” while unlink() deletes a file we pass to it from the file system.

Que.24: Can the value of a constant change during the script’s execution?

Ans. No, the value of a constant cannot be changed once it’s declared during the PHP execution.

Que.25: Can you extend a Final defined class?

Ans. No, you cannot extend a Final defined class. A Final class or method declaration prevents child class or method overriding.

Que.26: How we can get the number of elements in an array?

Ans. The count () function is used to return the number of elements in an array.

Que.27: What are PSRs? Choose 1 and briefly describe it.

Ans. PSRs are PHP Standards Recommendations that aim at standardising common aspects of PHP Development.

Que.28: How to declare an array in php?

Ans. Eg : var $arr = array('apple', 'grape', 'lemon');

Que.29: What is use of count() function in php ?

Ans. count() is used to count all elements in an array, or something in an object.

Que.30: How to set cookies in PHP?

Ans. Setcookie("sample", "ram", time()+3600);

Final Words:

Hope you are satisfied with PHP Interview Questions and Answers which is given on this page. If you have any doubt related to this page then you can comment in below section.

You may also like to check this Section

1 comment:

  1. This comment has been removed by a blog administrator.


Don't Add Comment with Spam Purpose

Powered by Blogger.