Header menu


Sunday, 19 January 2014

Best collection of php interview questions with answer for freshers

ANY SUGGESTION , QUESTION or CORRECTION is heartly welcome ... 

Ques 1. How can I disable the output of error message inside a HTML page?

Ans. Use  error_reporting(0);  to hide the error message in output.

Ques.2 Can we return other file formats (like Word, Excel, etc) using PHP script?

Ans. Yes we can create and return file formats(like Word, Excel etc) using php script.

Ques.3 Why we use session variable ?

Ans.  When we work on an application, we open it, do our stuff and then we close it. This is much like a (time interval)Session. The computer knows who we are. It knows when we started the application and when we ended it. But on the internet there is a problem,  web server does not know who we are and what we do. Because the HTTP address does not maintain state.
A PHP session solves this problem by allowing us to store user information on the server for later use (i.e. username, place,email id etc). However, session information is temporary and will be deleted as soon as the user has left the website. If we need a permanent storage then we have to store the data in a database.

Ques.4 Explain PEAR in php ?

Ans. PEAR stands for "PHP Extension and Application Repository". The purpose of PEAR is to provide:
A structured library of open-sourced code for PHP users
A system for code distribution and package maintenance
A standard style for code writing in PHP
PHP Foundation Classes (PFC),
PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community.

Ques. 5 What is the difference between echo and print() in php ?

Ans. echo - can output one or more strings
          echo - in only a statement is not a function

          print - can only output one string, and returns always 1
          print- is a function

Ques. 6 How would to take inner join of more than two tables ?
Ans. Click on link to see the answer   http://codesplanet.blogspot.in/2014/02/inner-join-between-more-than-two-tables.html

Ques. 7 What is the use of op_start() in php ?
Ans.  Click on link to see the answer     http://codesplanet.blogspot.in/2014/02/stophold-output-before-sending-of-header.html

Ques. 8 What is the difference between delete,truncate and drop ?
 Ans.  Click on link to see the answer http://codesplanet.blogspot.in/2014/02/explain-difference-between-delete.html

Ques. 9  An array contains number from 1 to 10 . One number is missing. Find the number missing with O(n) complexity.
 Ans.  Click on link to see the answer http://codesplanet.blogspot.com/2014/02/an-array-contains-number-from-1-to-100.html

Ques. 10 What are different types of adding css to a page ?
Ans. We can add css to a page using 3 methods :
         a) External css
         b) Internal css         
         c) Inline css 
Click on link to see the answer  http://codesplanet.blogspot.in/2014/05/in-how-ways-you-can-add-css-to-html-page.html