Why is it recommended to use prepared statements in PHP when interacting with a database?
- To improve code readability.
- To prevent SQL injection attacks.
- To reduce the need for database indexes.
- To enhance database schema design.
Prepared statements prevent SQL injection attacks by separating SQL code from user input, making it safer to execute database queries.
Loading...
Related Quiz
- To declare an associative array in PHP, you can use the array() function or the [] shorthand, and the keys are assigned ______.
- When connecting to a MySQL database using PDO, the DSN (Data Source Name) starts with the string ________.
- You are working on an online exam portal. To ensure that the user doesn't get the same session ID even if they retake the exam, what should you do at the beginning of each exam?
- You need to pass data into a block of code in your PHP script, perform some operations on the data, and then return a result. How would you accomplish this by defining and using a function?
- The print statement in PHP always returns ______.