You are building a web application that needs to process user-uploaded images. Which predefined PHP function can be used to get the width and height of an image?

  • getimagesize()
  • imagecreatefromjpeg()
  • imagecopy()
  • imagesetpixel()
The getimagesize() function in PHP is used to retrieve the width and height of an image, making it suitable for processing user-uploaded images.

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.

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.

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 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.

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.

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.

You have two arrays, one with keys and another with values. You need to combine them such that keys from the first array map to values from the second. Which PHP function would you use?

  • array_merge()
  • array_combine()
  • array_diff()
  • array_search()
The array_combine() function takes two arrays and creates a new array where the keys are from the first array and values from the second array.

To prevent session hijacking, it's a good practice to bind the session to the user's ________.

  • IP Address
  • Hardware Token
  • Browser Fingerprint
  • User Credentials
To prevent session hijacking, binding the session to the user's "Browser Fingerprint" is recommended. This involves tracking unique characteristics of the user's browser to ensure session continuity and security.

Which predefined PHP function can be used to reverse the order of the elements in an array?

  • array_reverse()
  • array_flip()
  • array_rotate()
  • array_shuffle()
The array_reverse() function is used to reverse the order of elements in an array. array_flip() flips the keys and values, while array_rotate() and array_shuffle() are not valid functions.