FREE! Click here to Join FunTrivia. Thousands of games, quizzes, and lots more!
Quiz about PHP Functions
Quiz about PHP Functions

PHP Functions Trivia Quiz


How well do you understand the built-in functions of PHP?

A multiple-choice quiz by kwdesigner. Estimated time: 4 mins.
  1. Home
  2. »
  3. Quizzes
  4. »
  5. Science Trivia
  6. »
  7. Computers
  8. »
  9. Software and Programming

Author
kwdesigner
Time
4 mins
Type
Multiple Choice
Quiz #
253,577
Updated
Dec 03 21
# Qns
10
Difficulty
Average
Avg Score
7 / 10
Plays
611
- -
Question 1 of 10
1. The date() function returns a formatted date or time. date('Y') would return which of following? Hint


Question 2 of 10
2. If you wanted to capitalize the first letter of each word in a string, which function would you use? Hint


Question 3 of 10
3. The function strip_tags($text, ' < p >'); will return what?
Hint


Question 4 of 10
4. The first parameter accepted by the mail() function is the subject line of the e-mail.


Question 5 of 10
5. Which of the following is not a valid function in the PHP MySQL library? Hint


Question 6 of 10
6. The file_exists() function does what? Hint


Question 7 of 10
7. If magic_quotes is turned on, PHP runs addslashes() on all GET, POST, and COOKIE data by default.


Question 8 of 10
8. To break a string into an array you would use this function... Hint


Question 9 of 10
9. This function merges two or more arrays into one array... Hint


Question 10 of 10
10. There are several built-in functions in PHP that can be used to return a random integer.



(Optional) Create a Free FunTrivia ID to save the points you are about to earn:

arrow Select a User ID:
arrow Choose a Password:
arrow Your Email:




Quiz Answer Key and Fun Facts
1. The date() function returns a formatted date or time. date('Y') would return which of following?

Answer: A full numeric representation of this year, 4 digits (like 2007)

The date function accepts dozens of parameters allowing you great flexibility in formatting a date.
2. If you wanted to capitalize the first letter of each word in a string, which function would you use?

Answer: ucwords()

ucfirst() makes the very first character (only) of a string uppercase.

strtoupper() capitalizes all characters in a string, while strtolower() makes all characters of the string lowercase.
3. The function strip_tags($text, ' < p >'); will return what?

Answer: The content of the string variable named text with all php and html tags stripped out except the paragraph tag.

Because strip_tags() does not actually validate the HTML, partial, or broken tags can result in the removal of more text/data than expected.
4. The first parameter accepted by the mail() function is the subject line of the e-mail.

Answer: No

The function definition is

mail(to,subject,message,headers,parameters)
5. Which of the following is not a valid function in the PHP MySQL library?

Answer: mysql_list_results()

mysql_errno() - Returns the error number of the last MySQL operation.

mysql_result() - Returns the value of a field in a recordset.

mysql_fetch_array() - Returns a row from a recordset as an associative array and/or a numeric array.
6. The file_exists() function does what?

Answer: Checks whether or not a file or directory exists

It's a good idea to use file_exists() before other functions to ensure that the file you need actually exists.
7. If magic_quotes is turned on, PHP runs addslashes() on all GET, POST, and COOKIE data by default.

Answer: Yes

The addslashes() function can be used to prepare a string for storage in a database by adding backslashes in front of predefined characters.

Since PHP runs addslashes() on all GET, POST, and COOKIE data by default, using addslashes() on strings that have already been escaped will cause double escaping.
8. To break a string into an array you would use this function...

Answer: explode()

implode() is the opposite of explode() and returns a string from the elements of an array.

chop() is an alias of rtrim(), which strips whitespace from the right side of a string.

strrev() reverses the contents of a string.
9. This function merges two or more arrays into one array...

Answer: array_merge()

array_multisort() sorts multiple or multi-dimensional arrays.

array_push()inserts one or more elements onto the end of an array.

array_intersect()compares array values and returns the matches.
10. There are several built-in functions in PHP that can be used to return a random integer.

Answer: Yes

mt_rand() produces a better random value four times faster than rand()!
Source: Author kwdesigner

This quiz was reviewed by FunTrivia editor crisw before going online.
Any errors found in FunTrivia content are routinely corrected through our feedback system.
11/21/2024, Copyright 2024 FunTrivia, Inc. - Report an Error / Contact Us