Which function in PHP returns a formatted string?

  • sprintf()
  • printf()
  • str_format()
  • format_string()
The sprintf() function in PHP is used to return a formatted string. It allows you to create formatted strings using placeholders and values, similar to printf() in C.

In dynamic forms where fields can be added or removed by the user, the server-side processing in PHP should use the ________ function to ensure data integrity.

  • 'isset()'
  • 'array_push()'
  • 'count()'
  • 'filter_var()'
The correct option is 'count().' In dynamic forms, where the number of fields can change, using 'count()' helps ensure data integrity by determining how many fields have been submitted and handling them appropriately. This is important for server-side validation.

How do you call a user-defined function in PHP?

  • call myFunction()
  • myFunction()
  • invokeFunction(myFunction)
  • execute myFunction()
To call a user-defined function in PHP, you simply use the function name followed by parentheses. For example, 'myFunction()' would call the function 'myFunction'.

A session token that is stored securely on the user's device and is used to recognize returning users without requiring them to log in again is called a ________.

  • Persistent Token
  • Short-lived Token
  • Session Identifier
  • Access Token
The session token that is securely stored on a user's device for recognizing returning users without requiring re-login is referred to as a "Persistent Token."

How can you determine if a variable is an array in PHP?

  • Using the is_array() function
  • Using the isArray() function
  • Using the isarray() function
  • Using the ArrayCheck() function
You can determine if a variable is an array in PHP by using the is_array() function, which returns true if the variable is an array.

How can you restrict the maximum file size for uploads in PHP through a form?

  • Using .htaccess file
  • Setting upload_max_filesize in php.ini
  • Using $_FILES['size']
  • Validating file size in PHP code
You can restrict the maximum file size for uploads in PHP through a form by setting the upload_max_filesize directive in the php.ini configuration file. This directive limits the size of uploaded files.

Which of the following data types in PHP is not scalar?

  • int
  • string
  • array
  • boolean
The non-scalar data type in PHP is an array. Arrays can hold multiple values and are not considered scalar because they are collections of values, not single values. Scalars include integers, strings, and booleans.

Which PHP superglobal array is used to collect form data sent via the GET method?

  • $_GET
  • $_POST
  • $_REQUEST
  • $_FORM
The $_GET superglobal array is used to collect form data sent via the GET method in PHP. It retrieves data from the URL's query string.

The function used to sort an indexed array in descending order is ________.

  • rsort
  • sort
  • ksort
  • asort
The function rsort is used to sort an indexed array in descending order, preserving the key-value associations.

The PHP superglobal used to collect form data sent via the POST method is ________.

  • $_GET
  • $_REQUEST
  • $_POST
  • $_SERVER
The PHP superglobal $_POST is used to collect form data sent via the POST method, allowing you to access form input data securely.