Using ________ ensures that even if two users have the same password, their hashed values will be different.
- Salted hashing
- Hash collision prevention
- Unique salting
- Hashed password variation
Utilizing salted hashing in password storage involves adding a unique random "salt" to each user's password before hashing it. This prevents identical passwords from having the same hashed value.
How can you differentiate between a 'directory' and a 'file' using PHP functions?
- is_dir() checks for directory
- file_exists() checks for a file
- scandir() lists the directory's contents
- is_file() checks for a file
The is_dir() function in PHP is used to determine if a given path is a directory. It's a key function for distinguishing directories from files.
Given the PHP expression $a && $b, if $a is false, what can be said about the evaluation of $b?
- $b will not be evaluated
- $b will be evaluated
- $b will always be false
- $b will always be true
In a logical AND (&&) expression, if the left operand ($a) is false, PHP does not evaluate the right operand ($b). This is called "short-circuiting" and is useful for efficiency and avoiding errors.
When accepting user file uploads, one should never trust the file's ________ as it can be easily spoofed.
- Extension
- Size
- Content-Type
- Location
Trusting the file extension is risky, as attackers can easily change it. It's better to verify the file's content and use other security measures.
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.
In PHP, the ________ function can be used to return a part of a string.
- substr()
- split()
- slice()
- cut()
The 'substr()' function in PHP is used to extract a portion of a string. It takes the original string and specifies the start and length of the substring to be returned.
A developer wants to store multiple values in a single variable. Which of the following data types in PHP should he/she use?
- Array
- String
- Integer
- Object
To store multiple values in a single variable, an array should be used in PHP. Arrays can hold various data types and are versatile for handling collections of data.
When dealing with form data in PHP, which function can be used to check if a particular input filter is supported?
- filter_has_var()
- validate_input()
- check_input_filter()
- is_filter_supported()
The filter_has_var() function is used to check if a particular input filter is supported for a specific form input. This is essential for input validation in PHP.