Int Web Prog Ch5
Which of the following consists of the PHP files that represent the data of the applications?
model
Which function can be used to redirect a request to another URL?
header()
Code example 5-1 function get_product($product_id) { global $db; $query = 'SELECT * FROM products WHERE productID = :product_id'; $statement = $db->prepare($query); $statement->bindValue(':product_id', $product_id); $statement->execute(); $product = $statement->fetch(); $statement->closeCursor(); return $product; } (Refer to code example 5-1) Which of the following is a proper PHP statement for calling the function in this example.
$product = get_product($product_id);
When you ________________ a request, all processing takes place on the server.
forward
When you ________________ an HTTP request, all processing takes place on the server before the response is returned to the browser.
forward
When you code a function in PHP, you start with the ________________ keyword.
function
To make a variable that is declared outside of a function usable inside the PHP function, which keyword can be used?
global
To make a variable that's declared outside a function available to the function, you must code the ________________ keyword.
global
When creating a function, ________________ can be included in the parentheses that follow the name.
parameters
When you code a function in PHP, you can list one or more ________________ that must be passed to the function.
parameters
What does the acronym MVC stand for?
Module-View-Controller
When you use the header() function to redirect a request,
a response is returned to the browser that tells it to request another page
Code example 5-1 function get_product($product_id) { global $db; $query = 'SELECT * FROM products WHERE productID = :product_id'; $statement = $db->prepare($query); $statement->bindValue(':product_id', $product_id); $statement->execute(); $product = $statement->fetch(); $statement->closeCursor(); return $product; } (Refer to code example 5-1) What does this function return when it is called?
an array of the columns in the row with the specified product ID
To call a function in PHP, you code the function name followed by a list of any ________________ that are required.
arguments
Which of the following receives requests from users, gets the appropriate data, and returns the appropriate views to the users?
controller
When you use the MVC pattern, the model consists of the PHP files that work with and represent the ________________ of the application.
data
Which function can be used to forward a request from one PHP file to another?
include()
One reason for using the header() function to redirect a request
is to have a PHP file run itself again
When you use the MVC pattern, you
make each layer as independent as possible
When you ________________ a request, the server returns a response that tells the browser to request another URL.
redirect
Which of the following is a term that refers to modifying the organization or structure of an application?
refactoring
To pass data back to the statement that calls a function, the function can use the ________________ statement.
return
Which type of statement should be included if the function should send a value back to where the function was called?
return
Which of the following is NOT a benefit of using the MVC pattern for an application?
the application runs more efficiently
When you use the MVC pattern, the controller gets the HTTP requests and then directs the use of the files that represent
the model and the view
When you use the MVC pattern, the ________________ consists of the HTML and PHP files that make up the user interface of the application.
view
Which of the following consists of the PHP and HTML files that represent the user interface of an application?
view