In PHP, the ________ function can be used to count the number of elements in an array, which can be useful when processing multiple form fields.

  • array_count()
  • count_array()
  • elements_count()
  • count()
In PHP, the 'count()' function is used to count the number of elements in an array, making it useful when processing multiple form fields as it helps you determine the array's size.

The PDO attribute that controls the error reporting mode is named ________.

  • PDO::ERRMODE_SILENT
  • PDO::ERRMODE_WARNING
  • PDO::ERRMODE_EXCEPTION
  • PDO::ERRMODE_ERRMODE
The PDO attribute that controls the error reporting mode is named PDO::ERRMODE_EXCEPTION, which makes PDO throw exceptions for errors.

What is the main reason for hashing passwords before storing them in a database?

  • To make passwords case-insensitive
  • To save storage space
  • To improve password visibility
  • To enhance security
Hashing passwords before storing them in a database enhances security. It ensures that the original password is not stored, making it much more difficult for attackers to retrieve user passwords in case of a breach.

In order to prevent other scripts on the server from accessing session files, PHP by default uses a ________ mechanism.

  • session.save_handler
  • session.file_permission
  • session.use_strict_mode
  • session.save_path
PHP uses a 'session.save_handler' mechanism to control where session data is stored, protecting it from unauthorized access.

You are building a profile page where users can upload their profile pictures. Which PHP function would you use to ensure the uploaded file is an image type?

  • getimagesize()
  • is_uploaded_file()
  • file_get_contents()
  • move_uploaded_file()
The getimagesize() function is used to determine the type of an uploaded file and ensure it's an image type, based on the returned image type information.

When connecting to a MySQL database using PDO, the DSN (Data Source Name) starts with the string ________.

  • "dsn:"
  • "pdo:"
  • "mysql:"
  • "database:"
When connecting to a MySQL database using PDO, the DSN typically starts with "mysql:" to specify the database type for the connection.

Which PHP function can be used to convert a string to lowercase?

  • strtolower()
  • toLowerCase()
  • strLower()
  • convertToLower()
To convert a string to lowercase in PHP, you use the strtolower() function. It's a built-in function that does this conversion.

You are implementing a feature where users can upload multiple documents at once. What changes would you make in the HTML form to handle multiple file inputs?

  • Use the multiple attribute
  • Create multiple file input fields
  • Use JavaScript to clone the input field
  • Use AJAX for file uploads
To allow users to upload multiple documents at once, you should use the multiple attribute on a single file input field. This enables users to select multiple files in a single input.

When handling multiple form fields, which HTML attribute allows users to select multiple values in an input field?

  • size
  • multiple
  • array
  • selected
The multiple attribute in an HTML