PHP Basic Interview Questions for freshers with answers



PHP Faqs PDF Download

Last week I met one of my old friend. He want to know the job  opportunities  in PHP. He had done a course in PHP from one local institute. But their training was terrific. My friend had  attended  2 interviews and failed to answer those questions. He asked me to prepare some basic questions that generally asked for PHP job interviews.

I asked him a simple questions first. Whats the full form of PHP ? After seeing his endless thinking, I started to answer. Initially it was “Personal Home Page“, but now its “PHP:Hypertext Preprocessor“. Its funny to think that Letter P in PHP stands for “PHP” itself. H stands for Hypertext and P stands for Preprocessor.

Next I told him, you need to remember one name always as like your father. He really surprised and asked what. I told you need to remember  “Rasmus Lerdorf” because he is initially created PHP and known as father of PHP. So obviously he should be the real person behind you job. May be your  interviewer  will ask this also.

What are the different methods to pass data for a form submission?
GET method and POST method. But never stop your answer by saying these two names. You should start telling about the difference between them. GET method simply send the data with url as query strings and it will be visible. But POST method will hide the passing data. So POST method will be suitable for submitting secure data like passwords and all. GET method url can be saved for future reference without again form submission. GET method url’s can be added to  favorite  and can be indexed by search engines. So the proper method will select as per the requirement. Maximum limit for data transfer is also different. POST method can pass more data than GET method. See now you have done a good answer for a simple questions from interviewer.

For an interview for PHP freshers, interviewer will try to grasp his basic knowledge than a wide knowledge. So you should be thorough and should provide a detailed answers for basic questions. Same time if you don’t  know the answer, tell him honestly  instead  of boring & wasting his time. That will increase your chance to face more questions that you know correct answers.

The main 10 topics in PHP that you can expect questions from are

  1. Loops ( For, Do, While )
  2. Arrays ( Creation, Searching , Different types , sorting )
  3. String functions ( Explode, search etc )
  4. Date & time
  5. Session & Cookies
  6. Mail function
  7. Ajax & Curl
  8. File handling ( Create, delete, write )
  9. Image & File upload
  10. Loop Termination Keywords ( Break, Continue, exit etc )

Writing a PHP exam or attending the interview can be a bit tricky. But here are a few questions you are likely to be asked:

  1. How does PHP work?

Ans

  • As a web design and scripting language, you can embed PHP into HTML or HTML5 code for designing an interactive website.
  • If you have some web template systems, web frameworks, or web content management systems, you can also combine PHP with them.
  • The processing of PHP code is done by an interpreter that is handled as a module in the server or as an executable in Common Gateway Interface (CGI). It is not uncommon to see developers execute PHP code using a command-line interface.
  1. What are the common uses of PHP?

Ans.

PHP is commonly used for the following for web pages:

  • It performs some system functions such as to create and open a file. It can also read a file, write into it, and close it.
  • It can be used to handle forms which include gathering data from files and saving data to a file.
  • You can use PHP to modify the contents of your database by adding, deleting, and editing the elements.
  • If you want to access or set cookies and cookies variables, PHP is handy.
  • You can set users restrictions to restrict the access of users to some of your website pages with PHP.
  • Interacting with the database is also possible by using PHP.
  1. What are the areas of application of PHP?

Ans.

Due to the versatility of PHP, you can use it for the following:

  • Generating PDF files.
  • Creating WordPress Plugins.
  • For processing and generating images.
  • Creating mailing lists.
  • Designing applications (apps).
  • Building an online community.
  • For creating graphs and charts.
  • For creating dynamic website templates.
  • It is a good Project Management tool.
  • For web applications.
  1. What are PHP variables?

Ans.

There are 8 PHP data types for constructing variables. These are:

  • Integers: For storing whole numbers without decimal numbers, eg. 2698.
  • Doubles: Doubles are used to store numbers with decimal numbers. Such numbers are called floating-point numbers, eg 3947.987.
  • Objects: These are defined by the programmer using PHP in a class and can be used according to the specific purposes for which they are defined.
  • Booleans: This can only hold two values, true or false.
  • Resources: These are special variables that can be used to gain access to resources that are outside the PHP because these variables hold references to such resources. A typical example of such external resources is database connections.
  • NULL: NULL is another special variable. It has a single value which is NULL.
  • Array: An array is a variable that contains other values in an indexed form.
  • 69_Which function would you use to format date information
  • 2_What are the method available in form submitting
  • 3_How can we submit from without a submit button
  • 4_How can we get the browser properties using php
  • 5_What is a Session
  • 6_How can we register the variables into a session
  • 7_How do you destroy a particular or all Sessions