When using transactions in PDO, the ________ method is used to roll back the current transaction.

  • rollback()
  • commit()
  • begin()
  • execute()
In PDO, the rollback() method is used to roll back the current transaction when using transactions.

Which keyword is used to execute a block of code regardless of whether an exception was thrown?

  • try...except
  • finally
  • always
  • unless
The finally keyword is used to execute a block of code regardless of whether an exception was thrown. This is useful for cleanup operations.

Which PHP superglobal holds server and execution environment information?

  • $GLOBALS
  • $_SERVER
  • $_ENV
  • $_SESSION
The $_SERVER superglobal in PHP holds information about the server and execution environment, such as headers and paths.

In a switch statement, what is used to match multiple values to a single case?

  • case
  • :
  • break
  • comma operator
In a switch statement, you can use the 'case' keyword to match multiple values to a single case, allowing multiple values to execute the same block of code.

You are developing an e-commerce site and need to store and retrieve user cart data during their browsing session. Which PHP superglobal would be most appropriate for this use-case?

  • $_SESSION
  • $_COOKIE
  • $_POST
  • $_GET
The $_SESSION superglobal is ideal for storing user-specific data across multiple pages during a browsing session, making it suitable for cart data.

In PHP, which function is used to encode a value into JSON format?

  • json_decode()
  • json_serialize()
  • encode_json()
  • json_encode()
The json_encode() function in PHP is used to encode a value into JSON format, making it suitable for data interchange.

To ensure session data is only transferred over secure connections, you can enable the ________ configuration directive in PHP.

  • session.use_trans_sid
  • session.cookie_secure
  • session.use_cookies
  • session.use_only_cookies
The 'session.cookie_secure' configuration directive ensures that session cookies are only transmitted over secure (HTTPS) connections, enhancing security.

Which of the following operators is used in PHP to check if two values are identical in both value and data type?

  • ==
  • ===
  • =
  • !=
The '===' operator in PHP checks for strict equality, meaning both the value and data type must match.

Which PHP superglobal array contains information about uploaded files?

  • $_GET
  • $_POST
  • $_FILES
  • $_REQUEST
The $_FILES superglobal array in PHP contains information about uploaded files. It provides details such as file name, file type, and file size for files uploaded via a form.

How can you modify the lifetime of a cookie in PHP?

  • By setting the expires attribute in setcookie() function with a future timestamp.
  • By using session_set_cookie_params()
  • By directly modifying the cookie file.
  • By changing the cookie name.
To modify the lifetime of a cookie in PHP, you can set the expires attribute in the setcookie() function with a future timestamp. This specifies when the cookie should expire.

Which of the following is a common security vulnerability that exploits web applications by injecting malicious SQL code?

  • SQL Injection
  • XSS (Cross-Site Scripting)
  • CSRF (Cross-Site Request Forgery)
  • Ransomware Attack
SQL Injection is a technique where an attacker injects malicious SQL code into input fields, potentially gaining unauthorized access to a database or system.

You're developing an e-commerce site and want to store user cart items temporarily. Which would be the most appropriate method to store this data without requiring user login?

  • Cookies
  • Session Storage
  • Local Storage
  • IndexedDB
The most appropriate method for storing user cart items temporarily without requiring login would be "Session Storage." It's a client-side storage solution that retains data during a single session and is perfect for this use case.