Q: What will be the output of the following PHP code?
< ?php
echo str_pad("Salad", 5)." is good.";
?>
A.SaladSaladSaladSaladSalad is good
B. is good SaladSaladSaladSaladSalad
C. is good Salad
D. Salad is good
Correct Option: DExplanation: The str_pad() function pads a string with a specified number of characters.
Q: How many functions does PHP offer for searching strings using POSIX style regular expression?
A.7
B.8
C.9
D.10
Correct Option: AExplanation: ereg(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and sql_regcase() are the functions offered.
Q: Which one of the following regular expression matches any string containing zero or one p?
A.p+
B.p*
C.P?
D.p#
Correct Option: CExplanation: P?
Q: How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions?
A.7
B.8
C.9
D.10
Correct Option: BExplanation: The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().
Q: What will be the output of the following PHP code?
Correct Option: DExplanation: The ucwords() function capitalizes the first letter of each word in a string. Its prototype follows:string ucwords(string str)
Q: PHP has long supported two regular expression implementations known as ___ and ___.
(i) Perl
(ii) PEAR
(iii) Pearl
(iv) POSIX
A.(i) and (ii)
B.(ii) and (iv)
C. (i) and (iv)
D.(ii) and (iii)
Correct Option: CExplanation: (i) and (iv)
Q: Which one of the following functions will convert a string to all uppercase?
A.strtoupper()
B.uppercase()
C.str_uppercase()
D.struppercase()
Correct Option: AExplanation: Its prototype follows string
strtoupper(string str).
Q: Which one of the following functions finds the last occurrence of a string, returning its numerical position?
A.strlastpos()
B.strpos()
C.strlast()
D.strrpos()
Correct Option: DExplanation: strrpos()
Q: Which one of the following functions can be used to concatenate array elements to form a single delimited string?
A.explode()
B.implode()
C.concat()
D.concatenate()
Correct Option: BExplanation: implode()
Q: [:alpha:] can also be specified as..
A. [A-Za-z0-9]
B.[A-za-z]
C. [A-z]
D.[a-z]
Correct Option: BExplanation: [:alpha:] is nothing but Lowercase and uppercase alphabetical characters.