murachs_php_4E_chapter05

rtf

School

Southern Illinois University, Carbondale *

*We aren’t endorsed by this school

Course

405

Subject

Computer Science

Date

Nov 24, 2024

Type

rtf

Pages

4

Uploaded by dustinmyers

Report
Chapter 5: How to use the MVC pattern to organize your code Murach's PHP and MySQL (4th Ed.) MULTIPLE CHOICE 1. When you use the MVC pattern, the controller gets the HTTP requests and then directs the use of the files that represent a. the model, the view, and the database b. the database and the view c. the model, the view, and the user interface d. the model and the view ANS: D 2. When you use the MVC pattern, you a. make each layer as independent as possible b. perform all data validation on the client c. use the pattern for every page in the application d. put all of the PHP code in the controller ANS: A 3. Which of the following is NOT a benefit of using the MVC pattern for an application? a. it’s easier to make changes to the application b. web designers can work independently on the view c. there’s less repetition of code d. it’s easier to test and debug the application e. the application runs more efficiently ANS: E 4. What does the acronym MVC stand for? a. Model-View-Controller c. Mixed-Vector-CPU b. Most-Valuable-Computer programmer d. Must-Verify-Constraints ANS: A 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; } 5. (Refer to code example 5-1) What does this function return when it is called?
a. an array of all the rows in the products table b. an array of all the rows with the specified category ID c. an array of the columns in the first row of the products table d. an array of the columns in the row with the specified product ID ANS: D 6. (Refer to code example 5-1) Which of the following is a proper PHP statement for calling the function in this example. a. $product = get_product($product_id); b. $product = get_product(product_id); c. $product = $get_product($product_id); d. $product = $get_product(product_id); ANS: A 7. When you use the header() function to redirect a request, a. a response is sent to the web server so it requests another page b. the web server returns a new page to the browser c. a response is returned to the browser that tells it to request another page d. the web server returns a new page to the controller of the MVC pattern ANS: C 8. One reason for using the header() function to redirect a request a. is that it’s more efficient than forwarding a request b. is to have a PHP file run itself again c. is to reduce the number of round trips that are required d. is to do all processing for the request on the server ANS: B 9. To make a variable that is declared outside of a function usable inside the PHP function, which keyword can be used? a. local c. public b. module d. global ANS: D 10. Which of the following is a term that refers to modifying the organization or structure of an application? a. interpolation c. instantiation b. refactoring d. inheritance ANS: B 11. When you ________________ a request, all processing takes place on the server. a. forward c. cancel b. initiate d. demand ANS: A
12. When you ________________ a request, the server returns a response that tells the browser to request another URL. a. forward c. cancel b. initiate d. redirect ANS: D 13. Which function can be used to forward a request from one PHP file to another? a. include() c. return() b. location() d. response() ANS: A 14. Which of the following consists of the PHP files that represent the data of the applications? a. controller c. inheriter b. model d. requester ANS: B 15. Which of the following consists of the PHP and HTML files that represent the user interface of an application? a. logic c. view b. model d. classes ANS: C 16. Which of the following receives requests from users, gets the appropriate data, and returns the appropriate views to the users? a. controller c. model b. view finder d. verifier ANS: A 17. Which of the following does a function start with in PHP? a. the function name c. the new keyword b. the function keyword d. the create keyword ANS: B 18. When creating a function, ________________ can be included in the parentheses that follow the name. a. parameters c. controllers b. properties d. formatters ANS: A 19. Which type of statement should be included if the function should send a value back to where the function was called? a. return c. parameter b. send d. argument ANS: A
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
20. Which function can be used to redirect a request to another URL? a. include() c. header() b. require() d. response() ANS: C 21. To pass one or more values to a function, the function must be defined with a. an accept statement for each value c. a variable for each value b. a get statement for each value d. a parameter for each value ANS: D 22. To call a function in PHP, you code the function name followed by a. a list of variables for any returned values b. an array for any returned values c. any arguments that are required d. any constants that are required ANS: C 23. What does the acronymn PRG stand for? a. Pass-Regress-Go c. Post-Regress-Go b. Pass-Redirect-Get d. Post-Redirect-Get ANS: D 24. The PRG pattern can be used to prevent the user from a. submitting a POST request b. submitting a GET request c. resubmitting a POST request d. resubmitting a GET request ANS: C 25. When you use the PRG pattern, a POST action writes data to the server and then a. redisplays the current page b. redirects to a GET request that executes the default action in the controller file c. forwards to the next page to be displayed d. resubmits the POST request ANS: B