menu

PHP Security


1. What is the purpose of the ctype_digit() function in PHP?

To check if a variable is a number or a numeric string

To check if a variable is a string

To check if a variable is an array

To check if a variable is an object


2. What is the purpose of the password_verify() function in PHP?

To encrypt data before storing it in a database

To hash passwords before storing them in a database

To validate user input

To convert special characters to HTML entities


3. Which of the following is a method to prevent SQL injection vulnerabilities in PHP?

Using SSL encryption

Storing passwords in plaintext

Allowing unlimited login attempts

Using prepared statements and parameterized queries


4. What is the purpose of the htmlspecialchars() function in PHP?

To encrypt passwords

To validate email addresses

To convert special characters to HTML entities

To generate random numbers


5. Which of the following is a method to prevent brute-force attacks on user passwords in PHP?

Using SSL encryption

Storing passwords in plaintext

Allowing unlimited login attempts

Using password hashing and salting


6. Which of the following is a method to prevent Cross-Site Scripting attacks in PHP?

Sanitizing user input

Using a CAPTCHA

Disabling JavaScript in the browser

Using SSL encryption


7. What is a SQL injection vulnerability?

A vulnerability that allows an attacker to execute arbitrary code on a system

A vulnerability that allows an attacker to include a file from a remote server

A vulnerability that allows an attacker to bypass authentication

A vulnerability that allows an attacker to manipulate database queries


8. Which of the following is a method to prevent session hijacking attacks in PHP?

Storing session IDs in plaintext

Using a fixed session ID

Using SSL encryption

Disabling session IDs


9. What is a Remote Code Execution vulnerability?

A vulnerability that allows an attacker to execute arbitrary code on a system

A vulnerability that allows an attacker to include a file from a remote server

A vulnerability that allows an attacker to bypass authentication

A vulnerability that allows an attacker to delete files on a system


10. What is the purpose of the password_hash() function in PHP?

To encrypt data before storing it in a database

To hash passwords before storing them in a database

To validate user input

To convert special characters to HTML entities