What is the significance of using question marks as placeholders in prepared statements in PHP?

Using question marks as placeholders in prepared statements in PHP is significant because it helps prevent SQL injection attacks by separating the SQL query logic from the user input data. This means that the user input data is treated as data rather than executable code, making it safer to execute queries with user input. Prepared statements with placeholders also improve performance as the database can optimize the query execution plan for repeated executions.

// Example of using question marks as placeholders in a prepared statement
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);