28. PHP Quiz

Test yourself

Choose an answer for each question. You get feedback straight away, and your best score is saved on this device.

Where does PHP code run?

  • In the visitor’s browser
  • On the web server
  • In the visitor’s operating system
  • Inside the CSS file

Which symbol starts every PHP variable name?

  • #
  • @
  • $
  • &

Which operator joins two strings in PHP?

  • The dot (.)
  • The plus sign (+)
  • The ampersand (&)
  • The comma (,)

Which comparison checks both value and type?

  • =
  • ==
  • =>
  • ===

Which loop is designed to go through every item of an array?

  • while
  • foreach
  • do...while
  • switch

Which superglobal holds values sent by a form that uses method="post"?

  • $_GET
  • $_SERVER
  • $_POST
  • $_FILES

What should you do before printing text that a visitor typed?

  • Escape it with htmlspecialchars()
  • Convert it with strrev()
  • Store it in a cookie
  • Nothing, because PHP escapes automatically

What is the difference between include and require when the file is missing?

  • There is no difference
  • include stops the script and require continues
  • Both only give a notice
  • require stops with a fatal error, and include only warns

Where is session data stored?

  • In the visitor’s browser
  • On the server, with only an ID kept in the browser
  • In the address bar
  • In the HTML page

What protects a database query from SQL injection?

  • Joining the input into the query with quotes
  • Using strtoupper() on the input
  • Prepared statements with placeholders
  • Hiding the database password

Which functions should you use to store and check passwords?

  • password_hash() and password_verify()
  • md5() and ==
  • base64_encode() and base64_decode()
  • strrev() and strlen()

What should happen to PHP error messages on a live website?

  • They should be shown to every visitor
  • They should be hidden from visitors and written to a log
  • They should be silenced with the @ operator
  • They should be stored in a cookie

What next?

You have finished the PHP course. Continue with the XML Tutorial, and use what you learned about forms, validation, and security when you build WordPress themes and plugins.

Scroll to Top