Docsity

CIST2351-PHP Programming I - Final Prep rated A.pdf, Exams of Nursing

Toggle sidebar
bg1
CIST2351-PHP Programming I - Final
Prep rated A
Which function searches for a regular expression in a string and returns 1 if the
pattern is found? - correct answer
✅
preg_match
What modifier can be added to the end of a regular expression in PHP to make it
case insensitive? - correct answer
✅
i
A list of functions or methods in the reverse order in which they were called is
a(n)________________. - correct answer
✅
stack trace
Regular expressions - correct answer
✅
can be used to completely validate some
types of user entries
Which of the following are coded patterns that you can use to search for matching
patterns in text strings? - correct answer
✅
regular expressions
Which of the following will match a new line in a PHP regular expression? - correct
answer
✅
/n
This pattern can be used to validate a five-digit zip code: - correct answer
✅
/^\d{5}$/
Which character is used to signify the beginning or the end of a word in a PHP
regular expression? - correct answer
✅
\b
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download CIST2351-PHP Programming I - Final Prep rated A.pdf and more Exams Nursing in PDF only on Docsity!

Prep rated A

Which function searches for a regular expression in a string and returns 1 if the pattern is found? - correct answer ✅preg_match What modifier can be added to the end of a regular expression in PHP to make it case insensitive? - correct answer ✅i A list of functions or methods in the reverse order in which they were called is a(n)________________. - correct answer ✅stack trace Regular expressions - correct answer ✅can be used to completely validate some types of user entries Which of the following are coded patterns that you can use to search for matching patterns in text strings? - correct answer ✅regular expressions Which of the following will match a new line in a PHP regular expression? - correct answer ✅/n This pattern can be used to validate a five-digit zip code: - correct answer ✅/^\d{5}$/ Which character is used to signify the beginning or the end of a word in a PHP regular expression? - correct answer ✅\b

Prep rated A

If you want to code a catch block that catches all types of exceptions and gets the message associated with the exception, you start the catch block like this: - correct answer ✅catch (Exception $e) { Which of the following will match any character that is NOT a letter, number, or underscore in a PHP regular expression? - correct answer ✅\W All of the arguments that are passed to a function are available in an array that can be accessed by using the - correct answer ✅func_get_args function If you create a function that passes an argument by reference, the function - correct answer ✅can change the original variable without using a return statement Which of the following is a function that is passed as an argument to another function? - correct answer ✅callback Which of the following is a nested function that has access to the outer function's local variables? - correct answer ✅closure Which term describes locations in the code that have access to a variable? - correct answer ✅scope To avoid the duplication of function names, you can - correct answer ✅Use namespaces

Prep rated A

To refer to a public property named categoryName for an object that's referenced by $category, you code - correct answer ✅$category->categoryName Which PHP function can be used to check if a specified class has been defined? - correct answer ✅class_exists Which of the following are variables that store the data for a class? - correct answer ✅properties A fundamental concept of object-oriented programming that groups related data and functionality in a class is called ____________________. - correct answer ✅encapsulation Which of the following is a special method executed when a new object is created from a class? - correct answer ✅constructor Which PHP function can be used to determine if an object is an instance of a class? - correct answer ✅is_a To delete a cookie, you - correct answer ✅set the cookie's value to an empty string and its expiration date to a time in the past Which PHP function can be used to end a session? - correct answer ✅session_destroy

Prep rated A

The $_SESSION variable for a session - correct answer ✅is an associative array ________________ provide a way for a web application to store information in the user's web browser and retrieve it every time the user requests a page. - correct answer ✅Cookies Which PHP function is used to create a cookie? - correct answer ✅setcookie To get the value of a cookie, you can use the autoglobal ______________ variable.

  • correct answer ✅$_COOKIE Once a session is started, which autoglobal can be used to get and set the user's data for a session? - correct answer ✅$_SESSION When you use session tracking, each HTTP request includes - correct answer ✅a cookie that stores the session ID If a request is not sent, a session will end by default after ________________ have passed. - correct answer ✅24 minutes Which of the following is a parameter of the setcookie function? - correct answer ✅all of these

Prep rated A

If you want to use echo statements to display a table of all of the codes and names, you could code those statements within a loop that starts like this: - correct answer ✅foreach ($country_codes as $code => $name) { Which of the following is a PHP function that returns the sum of the elements in an array? - correct answer ✅array_sum What output would be produced by the code below? $names = array('Ron Burgundy', 'Brick Tamland', 'Champ Kind', 'Veronica Corningstone', 'Brian Fantana'); echo $names[1]; - correct answer ✅Brick Tamland Which of the following is a PHP function that shuffles the values in an array in a random order? - correct answer ✅shuffle Which of the following is a PHP function that is used to count the number of times each value in an array is used? - correct answer ✅array_count_values Which of the following is a PHP function for sorting arrays? - correct answer ✅all of these When you create a DateInterval object, you pass it one argument that specifies one or more of the following: - correct answer ✅years, months, weeks, days, hours, minutes, seconds

Prep rated A

A _____ is an integer that represents a date and time as the number of seconds since midnight, January 1, 1970. - correct answer ✅timestamp Which method of a DateTime object can be used to determine an amount of time between two dates or times? - correct answer ✅diff Which of the following statements is NOT a valid way to create a timestamp named $birthdate that represents December 2, 1969? - correct answer ✅$birthdate = mktime(12, 2, 1969); If the date is December 25, 2014, what output would be produced by the code below? echo date('n/d/y h:i A'); - correct answer ✅12/25/2014 12:00 AM If the date is December 25, 2014, what output would be produced by the following code? echo date('n/j/y'); - correct answer ✅12/25/ Timestamps will encounter a(n) _____ problem if they are not converted to DateTime objects. - correct answer ✅Y2K If the date is December 25, 2014, what output would be produced by the code below? echo date('n/j/y'); - correct answer ✅12/25/

Prep rated A

Which of the following is NOT an escape sequence used in double-quoted strings in PHP? - correct answer ✅/c If you want to generate a random number that ranges from 1000 to 500,000 as a multiple of 100(1000, 1100, 1200, etc,), and store it in a variable named $number, you can use the code that follows. - correct answer ✅$number = mt_rand(10,5000); $number *= 100; Which of the following is a way to assign a string to a variable on PHP? - correct answer ✅all of these A "natural" comparison of two values - correct answer ✅puts both "09" and "9" before "10" If you want to round a number within an arithmetic expression, which function should you use? - correct answer ✅round Which type of loop will always execute its code at least once? - correct answer ✅do-while Which of the following statements will restart the execution of a loop? - correct answer ✅continue An if statement can be used to implement a _____ structure. - correct answer ✅selection

Prep rated A

What does $message contain after the following code executes? $statusCode = "403"; switch ($statusCode) { case "200": $message = "OK"; break: case "403": $message = "Forbidden"; break: case "404": $message = "Not Found"; break: default: $message = "Unknown Status"; break: - correct answer ✅Forbidden A switch statement in PHP starts by evaluating a switch _____. - correct answer ✅expression Which of the following can be used in a conditional expression? - correct answer ✅all of these What does $message contain after the following code executes?

Prep rated A

Assume that the statements that follow get the data from a text area named comments. After these statements are executed, how will the $comments_esc variable be displayed by an echo statement? $comments = filter_input(INPUT_POST, 'comments'); $comments_esc = htmlspecialchars($comments); - correct answer ✅With character entities for special characters Which attribute of a form element determines how the data is passed to a file? - correct answer ✅method Which optional attribute of a select element allows the user to select more than one option in a list box? - correct answer ✅multiple Which method of the form appends values to the URL to pass data? - correct answer ✅GET Which PHP function convert some special characters into character entities? - correct answer ✅htmlspecialchars Which character is used to separate the original URL from the parameters that are appended to it? - correct answer ✅? Which type of input element should be used on a form when the user can select only one of the options? - correct answer ✅radio

Prep rated A

Which HTML element is used to create a drop-down list? - correct answer ✅select