Which of the following SQL clauses is used to filter the results of a query?
- SELECT
- FROM
- WHERE
- ORDER BY
The 'WHERE' clause in SQL is used to filter the results of a query. It allows you to specify conditions that must be met for a row to be included in the result set.
In PHP, how can you check if a defined constant exists?
- defined()
- exists()
- constant_exists()
- is_constant_defined()
You can use the defined() function in PHP to check if a defined constant exists. It returns true if the constant is defined and false if it's not.
When a child class inherits from a parent class, it can also be referred to as a ________ relationship.
- Inheritance
- Association
- Aggregation
- Composition
In object-oriented programming, when a child class inherits from a parent class, it forms an inheritance relationship, inheriting properties and methods.
Which of the following PHP functions is commonly used to create a hashed password?
- encrypt()
- hash_password()
- password_hash()
- create_hashed_password()
The password_hash() function in PHP is commonly used for creating hashed passwords. It incorporates strong encryption algorithms and automatically generates a unique salt for each password, enhancing security.
When using PDO, which method is used to prepare a statement for execution?
- prepare()
- execute()
- query()
- bindParam()
The prepare() method in PDO is used to prepare an SQL statement for execution. It's typically used with placeholders to prevent SQL injection and to improve query performance by reusing the prepared statement with different parameter values.
The ________ function in PHP can be used to regenerate a session ID.
- session_regenerate_cookie
- session_regenerate_id
- session_reset_id
- session_destroy
The correct option is session_regenerate_id. It regenerates the session ID and helps enhance session security.
The ________ operator in PHP is used to check if two values are not equal.
- != (Not Equal)
- == (Equal)
- >= (Greater Than or Equal)
- !== (Identically Not Equal)
In PHP, the '!=' operator checks for inequality between two values. It returns true if the values are not equal.
In PHP, which keyword is used to define a constant?
- constant
- define
- const
- let
Constants in PHP are defined using the define function. It's not a keyword but a function used to create named constants with a specific value.
You are building a web application where the security of user data is paramount. Which password hashing algorithm would be most appropriate to use in PHP?
- password_hash()
- md5()
- sha1()
- bcrypt()
bcrypt() is the recommended choice for secure password hashing in PHP. It's a one-way hashing algorithm with salting, making it extremely resistant to brute-force and rainbow table attacks. In contrast, md5() and sha1() are outdated and less secure. password_hash() is a more recent option, but it's best used with bcrypt().
A variable that starts with a number in PHP will result in a ________.
- Syntax Error
- Warning
- Notice
- No Error
In PHP, a variable that starts with a number will result in a Syntax Error. Variable names must start with a letter or underscore in PHP.