Which PHP function can be used to strip tags from a string, often used to prevent XSS attacks?

  • strip_tags()
  • htmlspecialchars()
  • htmlentities()
  • xss_clean()
strip_tags() is used to remove HTML and PHP tags from a string, making it a useful tool for preventing cross-site scripting (XSS) attacks.

A class that cannot be instantiated and is intended to be inherited by other classes is known as a ________ class.

  • 'abstract'
  • 'final'
  • 'static'
  • 'interface'
An 'abstract' class in PHP is meant to be inherited by other classes. It can't be instantiated on its own and often contains abstract methods to be implemented by child classes.

The PHP function that compares two arrays and returns the differences is called ________.

  • array_diff()
  • array_merge()
  • array_intersect()
  • array_unique()
The array_diff() function in PHP compares two arrays and returns the differences between them, providing a useful tool for array comparison and manipulation.

Which network type spans a large geographic area, often connecting multiple cities or even countries?

  • LAN
  • MAN
  • PAN
  • WAN
WAN (Wide Area Network) is a network that covers a broad area, connecting multiple LANs that might be on opposite sides of the world. It can span cities, states, or even countries. The internet is the largest example of a WAN.

You are reviewing a colleague's PHP code and notice they are using raw SQL statements with user input directly in the query. What potential issue does this introduce?

  • SQL Injection vulnerabilities
  • Improved query performance
  • Better code readability
  • Enhanced database compatibility
Using raw SQL statements with user input directly in the query introduces SQL Injection vulnerabilities, a major security risk.

To ensure security, before saving an uploaded file, which of the following PHP functions can be used to check if the uploaded file is an expected type?

  • file_exists()
  • is_uploaded_file()
  • file_get_contents()
  • mime_content_type()
The correct function to check the uploaded file's type is mime_content_type(). This function retrieves the MIME type of a file, which is crucial for security, as it helps prevent malicious file uploads.

When debugging, it's useful to have a ________ environment that mirrors the production environment.

  • Test
  • Development
  • Staging
  • Production
A staging environment closely mimics the production environment, allowing for more realistic debugging and testing before deploying.

A common method to prevent stored XSS attacks is to store user input in its ________ form.

  • Encoded
  • Original
  • Encrypted
  • Compressed
Storing user input in its encoded form can prevent stored Cross-Site Scripting (XSS) attacks, as the data is less likely to be executed as code.

What is the concept in OOP where a subclass can have methods with the same name as methods in its parent class?

  • Method Overloading
  • Method Hiding
  • Method Overriding
  • Method Inheritance
The concept in OOP where a subclass can have methods with the same name as methods in its parent class is called "Method Overriding." It allows a child class to provide a specific implementation of a method defined in the parent class.

Which of the following SQL statements is used to retrieve data from a database?

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
The 'SELECT' statement is used to retrieve data from a database. It allows you to query and fetch specific data from one or more tables in a database.

Which function in PHP is used to make a connection to a MySQL database?

  • mysqli_query
  • mysql_connect
  • mysqli_connect
  • PDO::connect
The correct function is mysqli_connect. This function is used to establish a connection to a MySQL database in PHP using the MySQLi extension.

The session data in PHP is stored by default in the ________ directory on the server.

  • /tmp
  • /var/sessions
  • /sessions
  • /session_data
In PHP, session data is, by default, stored in the /tmp directory on the server. Understanding where session data is stored is crucial for managing and securing user sessions in web applications.