Web Designing MCQs

Top 20 MCQ Questions on Handling Strings in PHP

Pinterest LinkedIn Tumblr
This set of MCQ questions on handling strings in PHP includes the collections of the top 20 multiple-choice questions on the fundamentals of handling strings in PHP. It includes objective type questions on comparing two strings case-sensitively and case-insensitively, calculating the similarity and differences between two strings, manipulating string case, converting strings to and from HTML, tokenizing a string based on predefined characters, exploding a string based on a predefined delimiter, and retrieving part of a string.

Read Also: Top 20 MCQ Questions on Perl Regular Expressions in PHP

1) The … function performs a binary-safe, case sensitive comparison of two strings.
A. strspn()
B. strcspn()
C. strcmp()
D. strcomp()

2) The … function performs a case insensitive comparison of two strings.
A. strcaseicmp()
B. strcasecmp()
C. strcasecomp()
D. strspn()

3) The functions returs the length of the first segment of the string containing characters not found in another string.
A. strspn()
B. strcspn()
C. strcmp()
D. strcomp()

4) The functions returs the length of the first segment of the string containing characters also found in another string.
A. strspn()
B. strcspn()
C. strcmp()
D. strcomp()

5) The … function capitalizes the first letter of the string str if it is alphabetical.
A. strcap()
B. firstcap()
C. ucfirst()
D. ucasefirst()

6) The … function capitalizes the first letter of each word in a string.
A. ucwords()
B. firstcap()
C. ucfirst()
D. ucasewords()

7) The … function converts all newline (/n) characters in a string to their XHTML compliant equivalent, <br/>.
A. newline()
B. break()
C. nl2br()
D. nlbr()

8) Which of the following characters that htmlspacechars() can convert.
i. & (ampersand)
ii. ” (double quote)
iii. ‘ (Single quote)
A. i and ii only
B. i and iii only
C. ii and iii only
D. All i, ii and iii

9) The … function will delete all the HTML and PHP tags from the string altogether.
A. strip_tags()
B. delete_tags()
C. tags_strip()
D. tags_delete()

10) You can translate text to its HTML equivalent using the … function.
A. translate_text()
B. html_translation_text()
C. html_translation_table()
D. get_html_translation_table()

11) The … is capable of reversing the text-to-html translation and vice-versa.
A. translate_text_html()
B. html_translation_text()
C. html_text_flip()
D. array_flip()

12) The … function converts all characters in a string to their corresponding match found in a predefined array.
A. array_str()
B. strtr()
C. strtok()
D. array_flip()

13) The … function parses the string based on a predefined list of characters.
A. strstr()
B. strtr()
C. strtok()
D. strpos()

14) The … function finds the position of the first case-sensitive occurrence of a substring in a string.
A. strstr()
B. strtr()
C. strtok()
D. strpos()

15) The … function finds the position of the last occurrence of a string returning its numerical position.
A. strstr()
B. strtr()
C. strrpos()
D. strpos()

16) The … function returns the remainder of a string beginning with the first occurrence of a predefined string.
A. strstr()
B. strtr()
C. substr()
D. substr_count()

17) The … function returns the part of a string located between a predefined starting offset and length positions.
A. strstr()
B. strtr()
C. substr()
D. substr_count()

18) The … function returns the number of times one string occurs within another.
A. strstr()
B. strtr()
C. substr()
D. substr_count()

19) The … function removes various characters from the beginning of a string, including white space, the horizontal tab(\t), newline(\n), carriage return(\r), Null(\o), and vertical tab(\xob).
A. rtrim()
B. ltrim()
C. trim()
D. ctrim()

20) The function … offers information regarding the total number of words found in a string.
A. str_word_count()
B. str_count()
C. word_count()
D. count_words()

Answers

  1. C) strcmp()
  2. B) strcasecmp()
  3. B. strcspn()
  4. A. strspn()
  5. C. ucfirst().
  6. A. ucwords()
  7. C. nl2br()
  8. D. All i, ii and iii
  9. A. strip_tags()
  10. D. get_html_translation_table()
  11. D. array_flip()
  12. B. strtr()
  13. C. strtok()
  14. D. strpos()
  15. C. strrpos()
  16. A. strstr()
  17. C. substr()
  18. D. substr_count()
  19. B. ltrim()
  20. A. str_word_count()

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.