Scripting Homework 4 Answers

Preview:

DESCRIPTION

PHP MySQL homework 4 questions and answers

Citation preview

Homework 4 answers

Question 12 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 20 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 32 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 42 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.

strrch

r()

Question 52 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 62 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 72 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:

 Tru

e

Question 82 out of 2 points

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

Selected Answer:

 Tru

e

Question 92 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.

levenshtei

n()

Question 102 out of 2 points

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

Selected Answer:

 C.

strlen()

Question 112 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 122 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;WilliamClinton;GeorgeH.W.Bush;RonaldReagan;Jimmy

Carter

Question 132 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 142 out of 2 points

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

Selected Answer:

 Fals

e

Question 152 out of 2 points

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

Selected Answer:

 A.

{}

Question 162 out of 2 points

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

Selected Answer:

 Tru

e

Question 172 out of 2 points

What is the escape sequence for a single quotation mark?Answer

Selected Answer:

 B.

\'

Question 182 out of 2 points

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

Selected Answer:

 Tru

e

Question 192 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:

 Fals

e

Question 202 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>";

Recommended