Você está na página 1de 4

Homework 4 answers

Question 1
2 out of 2 points

Which of the following quantifiers can be used to specify the quantity of a match in a regular expression?(Choose all that apply.)
Answer Selected Answers: A.

question mark(?)
C.

asterisk(*)
D.

plus sign(+)

Question 2
0 out of 2 points

Which of the following character pairs match characters at the beginning and end of a string in a regular expression?
Answer Selected Answer: B.

|| and ||

Question 3
2 out of 2 points

Which of the following echo statements is invalid?


Answer Selected Answer: D.

echo '<p>Welcome to the 'combat zone'!</p>';

Question 4
2 out of 2 points

Which of the following functions performs a case-sensitive search for specified characters in a string and returns a sub-string from the last occurrence of the specified characters to the end of the string?
Answer Selected Answer: C.

strrchr()

Question 5
2 out of 2 points

Which of the following functions allows you to replace characters within a specified portion of a string?

Answer Selected Answer: C.

substr_replace()

Question 6
2 out of 2 points

Which of the following functions splits each character in a string into an array element?
Answer Selected Answer: A.

str_split()

Question 7
2 out of 2 points

Placing a backslash in front of an apostrophe tells the scripting engine that the apostrophe is to be treated as a regular keyboard character, and not as part of a single quotation mark pair that encloses a text string.
Answer Selected Answer: True

Question 8
2 out of 2 points

String comparison operators and most string comparison functions compare individual characters according to their ASCII value.
Answer Selected Answer: True

Question 9
2 out of 2 points

Which of the following functions return the number of characters you need to change for two string to be the same?
Answer Selected Answer: B.

levenshtein()

Question 10
2 out of 2 points

Which of the following functions returns the length of a string?


Answer Selected Answer: C.

strlen()

Question 11
2 out of 2 points

Which of the following operators can be used to join strings? (Check all that apply.)
Answer

Selected Answers: A.

.
C.

.=

Question 12
2 out of 2 points

$Presidents = "George W. Bush;William Clinton;George H.W. Bush;Ronald Reagan;Jimmy Carter"; $President = strtok($Presidents, " "); while ($President != NULL) { echo "$President<br />"; $President = strtok(" "); } The separator is a space. What will the output be?
Answer Selected Answer:

George W. Bush;William Clinton;George H.W. Bush;Ronald Reagan;Jimmy Carter

Question 13
2 out of 2 points

$Vegetable = "carrot"; echo "<p>Do you have any {$Vegetable}s?</p>"; This will display "__________".
Answer Selected Answer:

Do you have any carrots?

Question 14
2 out of 2 points

A \. is used to match any single character in a pattern.


Answer Selected Answer: False

Question 15
2 out of 2 points

Which of the following character sets do you use for complex string syntax?
Answer

Selected Answer:

A.

{}

Question 16
2 out of 2 points

If you include an array within a text string, you need to use complex string syntax.
Answer Selected Answer: True

Question 17
2 out of 2 points

What is the escape sequence for a single quotation mark?


Answer Selected Answer: B.

\'

Question 18
2 out of 2 points

One type of extraction functions returns a numeric position and the other returns a character or substring.
Answer Selected Answer: True

Question 19
2 out of 2 points

If you specify an empty string as the second argument of the strtok() function,or if the string does not contain any of the separators you specify,the strtok() function returns a value of FALSE.
Answer Selected Answer: False

Question 20
2 out of 2 points

To ensure the strpos() function (and other string functions) actually returns a Boolean value of FALSE and not a 0 representing the character in a string, which of the following is correct?
Answer Selected Answer:

$Email = "president@whitehouse.gov";
if (strpos($Email, "@") !== FALSE) echo"<p>The e-mail address contains an @ character.</p>";

else
echo "<p>The e-mail address does not contain an @ character.</p>";

Você também pode gostar