php interview questions and answers for experienced

1: php interview questions ,What is the value of $b in the following code?
$a=”5 USD”;
$b=10+$a;
echo $b;
?>Ans:15
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.

php interview questions

3:What is GPC?
G – Get
P – Post
C – Cookies

php interview questions

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.

php interview questions

5:Give some example for super global arrays?
$GLOBALS
$_GET
$_POST
$_SESSION
$_COOKIE
$_REQUEST
$_ENV
$_SERVER

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.

php interview questions

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.

php interview questions
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

php interview questions
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

php interview questions
10:Explain soundex() and metaphone().
 soundex()
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);
?>
metaphone()
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”);
?>