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.
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.
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.
In PHP, the ________ function can be used to count the number of elements in an array, which can be useful when processing multiple form fields.
- array_count()
- count_array()
- elements_count()
- count()
In PHP, the 'count()' function is used to count the number of elements in an array, making it useful when processing multiple form fields as it helps you determine the array's size.
The PDO attribute that controls the error reporting mode is named ________.
- PDO::ERRMODE_SILENT
- PDO::ERRMODE_WARNING
- PDO::ERRMODE_EXCEPTION
- PDO::ERRMODE_ERRMODE
The PDO attribute that controls the error reporting mode is named PDO::ERRMODE_EXCEPTION, which makes PDO throw exceptions for errors.
What is the main reason for hashing passwords before storing them in a database?
- To make passwords case-insensitive
- To save storage space
- To improve password visibility
- To enhance security
Hashing passwords before storing them in a database enhances security. It ensures that the original password is not stored, making it much more difficult for attackers to retrieve user passwords in case of a breach.
What does XSS stand for in the context of web security?
- Cross-Site Scripting
- Extra Security System
- External System Security
- Excess Server Stress
XSS (Cross-Site Scripting) is a security vulnerability where attackers inject malicious scripts into web pages viewed by other users, compromising their data and privacy.
When handling multiple select fields in a form, the name attribute should end with ________ to ensure all selected values are sent to the server.
- '[]'
- '*'
- '+'
- 'multiple'
To ensure all selected values are sent to the server, the name attribute should end with '[]' for multiple select fields. This tells PHP to treat the data as an array.
What will the strpos() function return if the substring is not found in the string?
- -1
- 0
- FALSE
- Null
The strpos() function in PHP returns -1 when the substring is not found in the string. It's important to check for -1 to determine if the substring is absent.
Which of the following is NOT a valid way to return multiple values from a PHP function?
- Using an array
- Using a class with multiple properties
- Using a comma-separated string
- Using multiple return statements
While using a comma-separated string is technically possible, it's not a good practice for returning multiple values. The other options are valid approaches for returning multiple values.