Which of the following is NOT a valid visibility keyword for properties and methods in PHP classes?

  • Private
  • Protected
  • Public
  • Final
'Final' is not a visibility keyword; it's used to indicate that a method or class cannot be extended or overridden. The valid visibility keywords are 'private,' 'protected,' and 'public.'

You are given a task to store student grades for different subjects. Which type of PHP array would be most efficient for this?

  • Associative Array
  • Numeric Array
  • Multidimensional Array
  • Linked List
An associative array would be the most efficient for storing student grades for different subjects. It allows you to associate each subject with its respective grade, making it easy to access grades by subject name.

When performing a DELETE operation in SQL, what happens if you omit the WHERE clause?

  • All rows are deleted
  • An error is thrown
  • No rows are deleted
  • The table structure is modified
If you omit the WHERE clause in a DELETE operation, it will delete all rows in the table. This is known as a "truncation," and it's a risky operation.

To remove unwanted tags and attributes from a string, you can use the PHP function ________.

  • strip_tags
  • sanitize_input
  • clean_string
  • filter_var
The strip_tags function in PHP is used to remove unwanted HTML and PHP tags and attributes from a string.

In a PHP script, you have a PDO prepared statement that updates user information based on user ID. However, sometimes the script fails silently without any error. Which of the following could be a method to diagnose the issue?

  • Enable PDO error mode
  • Add more SQL queries for error handling
  • Increase the PHP memory limit
  • Use unprepared SQL queries
Enabling PDO error mode will help identify errors in your SQL statements and provide detailed error messages, aiding in issue diagnosis.

You are developing a login form for a web application. To enhance security, which of the following techniques should you implement to verify user credentials?

  • Store Passwords in Plain Text
  • Use Secure Hashing (e.g., Bcrypt)
  • Implement Security Questions
  • Allow Unlimited Login Attempts
To enhance security, you should use secure hashing techniques like Bcrypt to store and verify passwords. Storing passwords in plain text is a major security risk, and other options can lead to vulnerabilities.

Which PHP function can be used to regenerate a session ID to prevent session fixation attacks?

  • session_regenerate_id()
  • session_start()
  • session_unset()
  • session_destroy()
The session_regenerate_id() function in PHP can be used to regenerate the session ID, which helps prevent session fixation attacks. It generates a new session ID and transfers the session data to the new ID. Regenerating the ID makes it difficult for attackers to predict and hijack a user's session.

Imagine you are reviewing someone else's PHP code and notice that they are using short open tags (
  • a) Short open tags can lead to slower script execution.
  • b) Short open tags are deprecated and may not be supported on all servers.
  • c) Short open tags improve code readability.
  • d) Short open tags are required for PHP scripts.
b) Short open tags are deprecated in PHP and may not be supported on all servers. This can lead to compatibility issues. Using standard

To repeatedly execute a block of code while a condition is true, you would use a ________ loop.

  • While
  • If
  • For
  • Switch
In PHP, the 'while' loop is used to execute a block of code repeatedly as long as a specified condition is true. It's great for tasks like iterating through arrays or processing data.

In PHP, the ________ function can be used to replace all occurrences of a search string with a replacement string in a given string.

  • replace()
  • str_replace()
  • modifyString()
  • swapString()
The str_replace() function in PHP is used to replace all occurrences of a search string with a replacement string in a given string. This is helpful for text manipulation and data processing tasks.