Wednesday, May 9, 2012

php interview questions and answers for experienced

1:What is the value of $b in the following code?
    $a="5 USD";
    echo $b;

2:What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?
  In the get method the data made available to the action page ( where data is received ) by the URL so data can be seen in the address bar. Not advisable if you are sending login info like password etc.

In the post method the data will be available as data blocks and not as query string.
3:What is GPC?
G – Get
P – Post
C – Cookies
4:What are super global arrays?
All variables that come into PHP arrive inside one of several special arrays known collectively as the superglobals. They're called superglobal because they are available everywhere in your script, even inside classes and functions.
5:Give some example for super global arrays?
6:What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading?

MOVE_UPLOAD_FILE :   This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
Copy :Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise.
7:When I do the following, the output is printed in the wrong order:

function myfunc($argument) {
        echo $argument + 10;
      $variable = 10;
 echo "myfunc($variable) = " . myfunc($variable);

What's going on?
To be able to use the results of your function in an expression (such as concatenating it with other strings in the example above), you need to return the
value, not echo it.
8:What are the Formatting and Printing Strings available in PHP?
Function                     Description
printf()    :                 Displays a formatted string
sprintf()   :                 Saves a formatted string in a variable
fprintf()   :                 Prints a formatted string to a file
number_format()  :   Formats numbers as strings
9:Explain the types of string comparision function in PHP.
      Function              Descriptions
strcmp()             :Compares two strings (case sensitive)
strcasecmp()      :Compares two strings (not case sensitive)
strnatcmp(str1, str2) :Compares two strings in ASCII order, but
                                    any numbers are compared numerically
strnatcasecmp(str1, str2):Compares two strings in ASCII order,
                                          case insensitive, numbers as numbers
strncasecomp()  : Compares two strings (not case sensitive)
                            and allows you to specify how many characters
                             to compare
strspn()             : Compares a string against characters represented
                             by a mask
strcspn()           : Compares a string that contains characters not in
                            the mask
10:Explain soundex() and metaphone().
The soundex() function calculates the soundex key of a string. A soundex key is a four character long alphanumeric string that represent English pronunciation of a word. he soundex() function can be used for spelling applications.
$str = "hello";
echo soundex($str);
The metaphone() function calculates the metaphone key of a string. A metaphone key represents how a string sounds if said by an English speaking person. The metaphone() function can be used for spelling applications.
echo metaphone("world");
11:What do you mean range()?
      Starting from a low value and going to a high value, the range() function creates an array of consecutive integer or character values. It takes up to three arguments: a starting value, an ending value, and an increment value. If only two arguments are given, the increment value defaults to 1.
Example :
echo range(1,10); // Returns 1,2,3,4,5,6,7,8,9,10
12:How to read and display a HTML source from the website url?
$fh=fopen("$filename", "r");
while( !feof($fh) ){
$contents=htmlspecialchars(fgets($fh, 1024));
print "
?>13:What is properties of class?
Class member variables are called "properties". We may also see them referred to using other terms such as "attributes" or "fields", but for the purposes of this reference we will use "properties". They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration. This declaration may include an initialization, but this initialization must be a constant value that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
14:How to use HTTP Headers inside PHP? Write the statement through which it can be added?
                HTTP headers can be used in PHP by redirection which is written as:
The headers can be added to HTTP response in PHP using the header(). The response headers are sent before any actual response being sent. The HTTP headers have to be sent before taking the output of any data. The statement above gets included at the top of the script.
15:Why we used PHP?
Because of several main reason we have to use PHP. These are:
1.PHP runs on many different platforms like that Unix,Linux and Windows etc.
2.It codes and software are free and easy to download.
3.It is secure because user can only aware about output doesn't know how that comes.
4.It is fast,flexible and reliable.
5.It supports many servers like: Apache,IIS etc.
16:Arrays  in PHP?
 Create array in PHP to solved out the problem of writing same variable name many time.In this we create a array of variable name and enter the similar variables in terms of element.Each element in array has a unique key.Using that key we can easily access the wanted element.Arrays are essential for storing, managing and operating on sets of variables effectively. Array are of three types:
1.Numeric array
2.Associative array
3.Multidimensional array
 Numeric array is used to create an array with a unique key.Associative array is used to create an array where each unique key is associated with their value.Multidimensional array is used when we declare multiple arrays in an array.
17:What is foreach loop in  php?
foreach:Uses, When When we want execute a block of code for each element in an array.
foreach (array as value)
    code will be executed;
$arr=array("one", "two", "three");
foreach ($arr as $value)
  echo "Value: " . $value . "

18:How we used $_get and $_post variable in PHP?
   We know that when we use $_GET variable all data_values are display on our URL.So,using this we don't have to send secret data (Like:password, account code).But using we can bookmarked the importpage.
 We use $_POST variable when we want to send data_values without display on URL.And their is no limit to send particular amount of character.
Using this we can not bookmarked the page.
19:Why we use $_REQUEST variable?
We use $_REQUEST variable in PHP to collect the data_values from $_GET,$_POST and $_COOKIE variable.
R4R Welcomes You .

You are years old!
20:How we handle errors in PHP?Explain it?
In PHP we can handle errors easily.Because when error comes it gives error line with their respective line and send error message to the web browser.
When we creating any web application and scripts. We should handle errors wisely.Because when this not handle properly it can make bg hole in security.
In PHP we handle errors by using these methods:
1.Simple "die()" statements
2.Custom errors and error triggers
3.Error reporting
21: How we use Custom errors and error triggers error handling method in PHP?
In Custom errors and error triggers,we handle errors by
using self made functions.
1.Custom errors : By using this can handle the multiple
errors that gives multiple message.
In this syntax if we want that our error handle, handle
only one error than we write only one argument otherwise
for handle multiple errors we can write multiple arguments.

//function made to handle errorfunction
custom_Error($errorno, $errorstr) 
   echo \\\"Error: [$errorno] $errorstr\\\";  }
//set error handler like that
//trigger to that error

2.error trigger : In PHP we use error trigger to handle
those kind of error when user enter some input data.If
data has an error than handle by error trigger function.

$i=0;if ($i<=1)
trigger_error(\\\"I should be greater than 1 \\\");
In this trigger_error function generate error when i is
less than or greater than 1.
22:What do you understand about Exception Handling in PHP?
In PHP 5 we introduce a Exception handle to handle run time exception.It is used to change the normal flow of the code execution if a specified error condition occurs.
An exception can be thrown, and caught("catched") within PHP. Write code in try block,Each try must have at least one catch block. Multiple catch blocks can be used to catch different classes of exceptions.
Some error handler methods given below:
1.Basic use of Exceptions
2.Creating a custom exception handler
3.Multiple exceptions
4.Re-throwing an exception
5.Setting a top level exception handler
23: What is the difference b/n 'action' and 'target' in form tag?
    Action attribute specifies where to send the form-data when
a form is submitted.
    The target attribute specifies where to open the action URL.
         _blank – open in new window
        _self- Open in the same frame as it was clicked
        _parent- Open in the parent frameset
        _top- Open in the full body of the window
        Framename- Open in a named frame24:What do you understand about PHP accelerator ?
Basically PHP accelerator is used to boost up the performance of PHP programing language.We use PHP accelerator to reduce the server load and also use to enhance the performance of PHP code near about 2-10 times.In one word we can say that PHP accelertator is code optimization technique.
26:How we use ceil() and floor() function in PHP?
ceil() is use to find nearest maximum values of passing value.
echo $ans_var;
floor() is use to find nearest minimum values of passing value.
echo $ans_var; 
27:What is the answer of following code
echo 1< 2 and echo 1 >2 ?

Output of the given code are given below:
echo 1<2
output: 1
echo 1>2
output: no output
28: What is the difference b/w isset and empty?
The main difference b/w isset and empty are given below:
isset: This variable is used to handle functions and checked a variable is set even through it is empty.
empty: This variable is used to handle functions and checked either variable has a value or it is an empty string,zero0 or not set at all.





  1. Good questions
    i would like to add some more question


  2. Hi,


    More Interview questions & answers are available on :

  3. Hi,

    Great healp. thanks for the post.
    please check $_SERVER for the server variable

  4. Thanks for the help...

  5. Nice it all.. please add more questions..

  6. Thank you Deepak,Nice Job

  7. Deepak, thanks - great questions!

    good set of questions here too:

    PHP Interview Questions experienced

  8. Good answer writing make more pls...

  9. Really a good collections ... thanks Deepak

  10. good questions
    more questions are required

  11. good collections ...

    Check More Interview questions & answers are here

    PHP Interview Questions and answers

  12. Thanks for the nice collections. You want to attend any quiz or free html templates. Please have a look. this site will help you lot.

  13. All answers well explained. But questions are not enough for interview preparation.

  14. Good Question collection. Thanks for your effort.

  15. Thanks for the nice collections. All answers well explained and will definitely work for job seeker thanks.

    PHP Development company India
    PHP Web Development Company India
    web development company india

  16. Superb , way to explain..

  17. please add some more technical and practical question

  18. Hi
    Good post.
    You can check latest php code on

  19. good evening sir ,very nice but i want advanced interview question

  20. This comment has been removed by the author.

  21. Great post . It takes me almost half an hour to read the whole post. Definitely this one of the informative and useful post to me. Thanks for the share and plz visit my site Web Design Company Elesoftech is a leading offshare web development,mobile application, iphone application.

  22. Thanks for your excellent funeral experience and I also had such an experience
    Website Design Companies Bangalore

  23. Very nice collection ... please go threw this link for more php interview questions and answers ...

  24. After examine a couple of the weblog posts on your web site now, and I actually like your means of blogging. It was very very good and informative.
    Website Design and Development Company India

  25. Hi,

    Thank you very much for the info. It was a nice debate about PHP. Have a look on our site to see lots more


  26. Thanks a lot .. i was searching for this kind of content.

    web designing company in indore

  27. thanks for this....

  28. Nice collections of questions and answer


  29. Thank you for sharing valuable information. Good website design and development but cheap rate visit us : Software Development Company Jaipur

  30. Thanks friend your all interview questions and answers is really good and i love all posts and Php really good for you web development and even best for PHP Development company India and PHP Web Development Company India.

  31. The article shared was awesome. Love to read this kind of article. Thanks for sharing.
    PHP Web Development Company in Indore | PHP Website Design in Indore

  32. Thank you for your sharing this informative blog. I have bookmarked this page for my future reference. Recently I did PHP course at a leading academy. If you are looking for best PHP Training Institutes in Chennai visit FITA IT training and placement academy

  33. It was really a wonderful article and I was really impressed by reading this blog. We are giving all software Course Online Training. The HTML5 Training in Chennai is one of the reputed Training institute in Chennai. They give professional and real time training for all students.


  34. It’s too informative blog and I am getting conglomerations of info’s about Php interview questions and answer .Thanks for sharing, I would like to see your updates regularly so keep blogging.
    PHP Course Chennai


  35. Thanks for sharing your view to our knowledge’s, its helps me plenty keep sharing…
    Angular training in chennai

  36. Thanks for sharing this valuable information to our vision
    PHP Training in Chennai, Fita Chennai Reviews

  37. Here i had a opportunity to collect php interview question , i hope it will useful for my interview preparation thanks for sharing keep blogging...
    PHP Training Chennai | PHP Course in Chennai

  38. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
    Salesforce training in Chennai|Salesforce training institute in Chennai

  39. Brilliant article. The information I have been searching precisely. It helped me a lot, thanks. Keep coming with more such informative article. Would love to follow them.
    PHP Training in Chennai | HTML5 Training in Chennai | Android Training in Chennai

  40. Brilliant article. Found it helpful. We at fita, provide Java Training in Chennai, along with placement assurance. Reach us if you are interested in Java Training in Chennai. Thank you, Java Training in Chennai

  41. Thanks for the article. It has given me some basic ideas of what I have been searching for. Come up with more such articles.
    Dot Net Training in Chennai | Dot Net Training in Chennai | Dot Net Training in Chennai

  42. Thank you for the informative post. It was thoroughly helpful to me. Keep posting more such articles and enlighten us.
    Software testing training in Chennai | Software testing training in Chennai | Software testing training in Chennai

  43. Hi I’m Rahul doing my final year BE in computer. I have not got placed in any campus recruitment, so planning to go for QTP Training in Chennai. So kindly help me by guiding on where I could do QTP Training in Chennai which also helps in placement services.

  44. Hello, Can anyone help me about the career path and chances in choosing Android? I have planned to do Android Courses. Someone suggest which is the Best Android Training in Chennai where I could get placement services also?

  45. Hi, PHP is a server-side general purpose scripting language used for web development, which is used in almost all personal blogs. It is a very easy to understand language that can be easily learnt with a proper PHP Training in Chennai. You can join a course at FITA, where the best PHP Training in Chennai is taken, and excel as a web developer.