PHP Interview Question and Answers

36. How many open modes available when a file open in PHP?
  r  , r+  , w  , w+  , a  , a+  , x  , x+ 
 
Your Name Your Email-ID
Your Answer
37. Explain the types of string comparision function in PHP.
 
  Function Descriptions
1. strcmp() Compares two strings (case sensitive)
2. strcasecmp() Compares two strings (not case sensitive)
3. strnatcmp(str1, str2); Compares two strings in ASCII order, but any numbers are compared numerically
4. strnatcasecmp(str1, str2); Compares two strings in ASCII order, case insensitive, numbers as numbers
5. strncasecomp() Compares two strings (not case sensitive) and allows you to specify how many characters to compare
6. strspn() Compares a string against characters represented by a mask
7. strcspn() Compares a string that contains characters not in the mask
 
Your Name Your Email-ID
Your Answer
38. 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.
<?php
$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.
<?php
echo metaphone("world");
?>
 
Your Name Your Email-ID
Your Answer
39. Explain the types of functions for Splitting String?
 
  Function Descriptions
1. split() Splits a string into an array by using a regular expression as the delimiter.
2. spliti() Splits a string into an array by a regular expression and is case insensitive.
3. str_split() Converts a string into an array where the size of the elements can be specified
4. preg_split() Splits up a string by a Perl compatible regular expression and returns an array of substrings
5. explode() Splits up a string by another string (not a regular expression) and returns an array
6. implode() Joins array elements together by a string and returns a string
 
Your Name Your Email-ID
Your Answer
40. Explain Whitespace Characters.
 
Whitespace Character ASCII Value(Decimal/Hex) Descriptions
" " 32 (0x20)) An ordinary space
"\t" 9(0x0) A tab.
"\n" 10(0x0A) A newline (line feed).
"\r" 13(0x0D)) A carriage return.
"\0" 0(0x00)) The NULL-byte.
"\x0B" 11(0x0B)) A vertical tab.
 
Your Name Your Email-ID
Your Answer