Practice Quiz

Intro to PHP

Instructions

This practice quiz is posted to help you prepare for the final exam. The questions here are similar to those that will be on the exam. (Some of them may actually be on the exam.) Mark your selections using the radio buttons. Answers are shown by clicking the button at the bottom of the page.

  1. Which method works for validating PHP scripts using the W3C validator?
    1. Copy and paste the PHP code into Validate by Direct Input.
    2. Provide the address of the page (on a server) to Validate by URI.
    3. Upload the PHP file using Validate by File Upload
    4. all of the above
  2. A client-side scripting system like PHP
    1. conceals the script code from the visitor.
    2. can draw on resources on the server such as databases.
    3. allows content to be tailored to the visitor's browser.
    4. all of the above.
  3. If your PHP script has a syntax error,
    1. the error message will appear in the web page if the server is appropriately configured.
    2. the error message will appear in the server log.
    3. the error message will appear in the browser web console.
    4. both (a) and (b)
  4. PHP superglobal variables
    1. are user-defined variables shared by a set of pages.
    2. are user-defined variables shared by different functions in a PHP script.
    3. are variables provided and pre-set by the server.
    4. are variables shared between PHP and the JavaScript in a page.
  5. In PHP, the difference between single quotes (') and double quotes (") as string delimiters is
    1. double quotes may not be used for keys indexing an associative array.
    2. variables are expanded inside single quotes but not double quotes.
    3. variables are expanded inside double quotes but not single quotes.
    4. no difference.
  6. Which statement about PHP functions is false?
    1. A function must return a value.
    2. In a function declaration, the keyword function is required.
    3. Optional function arguments are permitted, and can be given default values.
    4. By default, function arguments are passed by value.
  7. which of the following is a correct way to obtain the square root of a variable $x in PHP?
    1. Math.sqrt($x)
    2. $x.sqrt()
    3. sqrt($x)
    4. $x^0.5