Sail E0 Webinar

MCQs

Total Questions : 14 | Page 1 of 2 pages
Question 1. How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.
  1.    7
  2.    8
  3.    9
  4.    10
 Discuss Question
Answer: Option B. -> 8


The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().


Question 2. Say we have two compare two strings which of the following function/functions can you use?(i) strcmp()(ii) strcasecmp()(iii) strspn()(iv) strcspn()
  1.    (i) and (ii)
  2.    (iii) and (iv)
  3.    None of the mentioned
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


All of the functions mentioned above can be used to compare strings in some or the other way.


Question 3. What will be the output of the following
PHP code?
< ?php
$title = "O'malley wins the heavyweight championship!";
echo ucwords($title);
?>
  1.    O'Malley Wins The Heavyweight Championship!
  2.    O'malley Wins The Heavyweight Championship!
  3.    O'Malley wins the heavyweight championship!
  4.    o'malley wins the heavyweight championship!
 Discuss Question
Answer: Option D. -> o'malley wins the heavyweight championship!


The ucwords() function capitalizes the first letter of each word in a string. Its prototype follows:string ucwords(string str)


Question 4. Which one of the following functions will convert a string to all uppercase?
  1.    strtoupper()
  2.    uppercase()
  3.    str_uppercase()
  4.    struppercase()
 Discuss Question
Answer: Option A. -> strtoupper()


Its prototype follows stringstrtoupper(string str).


Question 5. What will be the output of the following PHP code?
< ?php
echo str_pad("Salad", 5)." is good.";
?>
  1.    SaladSaladSaladSaladSalad is good
  2.    is good SaladSaladSaladSaladSalad
  3.    is good Salad
  4.    Salad is good
 Discuss Question
Answer: Option D. -> Salad is good


The str_pad() function pads a string with a specified number of characters.


Question 6. Which one of the following functions can be used to concatenate array elements to form a single delimited string?
  1.    explode()
  2.    implode()
  3.    concat()
  4.    concatenate()
 Discuss Question
Answer: Option B. -> implode()


implode()


Question 7. Which one of the following functions finds the last occurrence of a string, returning its numerical position?
  1.    (a) strlastpos()
  2.    strpos()
  3.    strlast()
  4.    strrpos()
 Discuss Question
Answer: Option D. -> strrpos()


strrpos()


Question 8. PHP has long supported two regular
expression implementations known as ___ and
___.(i) Perl(ii) PEAR(iii) Pearl(iv) POSIX
  1.    (i) and (ii)
  2.    (ii) and (iv)
  3.    (i) and (iv)
  4.    (ii) and (iii)
 Discuss Question
Answer: Option C. -> (i) and (iv)


(i) and (iv)


Question 9. What will be the output of the following PHP code?
< ?php
$url = "nachiketh@example.com";
echo ltrim(strstr($url, "@"),"@");
?>
  1.    nachiketh@example.com
  2.    nachiketh
  3.    nachiketh@
  4.    example.com
 Discuss Question
Answer: Option D. -> example.com


The strstr() function returns the remainder of a string beginning with the first occurrence of a predefined string.


Question 10. Which one of the following regular expression matches any string containing zero or one p?
  1.    p+
  2.    p*
  3.    P?
  4.    p#
 Discuss Question
Answer: Option C. -> P?


P?


Latest Videos

Latest Test Papers