When validating user credentials, it's essential to use a function that compares hashed values in a way that is:
- Constant Time (O(1))
- Linear Time (O(n))
- Exponential Time (O(2^n))
- Logarithmic Time (O(log n))
The key to secure credential validation is to use a constant-time comparison to avoid timing attacks. A constant-time comparison ensures that the function takes the same amount of time regardless of whether the comparison succeeds or fails. This makes it harder for attackers to infer information based on timing differences.
To ensure a file resource is closed and memory is freed up, you should use the ________ function in PHP.
- close_file()
- flush()
- fclose()
- release_memory()
The fclose() function in PHP is used to close an open file resource. This ensures that the file is properly closed, and associated memory is released.
The PHP function ________ can be used to verify if a given password matches a hashed password.
- password_verify()
- hash_compare()
- verify_password()
- compare_passwords()
The password_verify() function is specifically designed for verifying a password against its hashed value, enhancing security in user authentication processes. This is a key concept in web security.
In a SQL JOIN operation, which keyword is used to return all records when there is a match in one of the tables?
- INNER JOIN
- RIGHT JOIN
- LEFT JOIN
- FULL JOIN
In a SQL JOIN operation, the LEFT JOIN keyword is used to return all records from the left (or first) table, and the matched records from the right (or second) table. If there's no match in the right table, NULL values are returned. This is useful when you want to retrieve all records from one table and only matching records from another. It's commonly used to create inclusive result sets.
An array that has named indexes instead of numeric is called a(n) ________ array.
- Associative Array
- Indexed Array
- Numeric Array
- Sequential Array
An array with named indexes is known as an Associative Array. In PHP, you can use strings as keys to access values in the array, making it very flexible.
The $_FILES superglobal in PHP has an array key named ________ which provides the original name of the uploaded file.
- $_FILES['file']
- $_FILES['name']
- $_FILES['original']
- $_FILES['temp_name']
In PHP, the '$_FILES' superglobal contains information about the uploaded files, and the 'name' key specifically provides the original name of the uploaded file.
Which of the following is NOT a valid exception handling method in PHP?
- try-catch
- set_exception_handler()
- throw
- onError()
onError() is not a valid exception handling method in PHP. The correct methods are try-catch, and set_exception_handler()
In a switch-case structure, the ________ keyword is used to specify the default action when no case matches.
- if
- default
- else
- break
In a switch-case structure, the default keyword specifies the action when no case matches the switch expression.
In PHP OOP, what does the term "inheritance" mean?
- Passing properties
- Extending a class
- Object duplication
- Class encapsulation
In PHP Object-Oriented Programming, "inheritance" means extending a class to create a new class with the same properties and methods as the parent class.
Consider a scenario where you need to ensure that a particular piece of code only executes once, regardless of how many times a function is called. Which PHP feature or function would you utilize?
- Singleton Pattern
- Static Variable
- sleep()
- exit()
To ensure a piece of code only executes once, you can use a static variable inside a function to keep track of whether it has already been executed.
Constants in PHP are by default ________ (case-sensitive/case-insensitive).
- case-insensitive
- uppercase-sensitive
- lowercase-sensitive
- case-sensitive
Constants in PHP are, by default, case-sensitive. This means that constant names are distinct based on their case (e.g., "CONSTANT" and "constant" are considered different).
The control structure that allows for multiple conditions to be checked in a single statement is called ________.
- Switch
- If
- For
- While
In PHP, the 'switch' control structure allows you to check multiple conditions in a single statement, making your code more efficient and organized.