What resources or tutorials can PHP developers refer to for learning about common pitfalls and best practices in coding?

When coding in PHP, developers may encounter common pitfalls such as SQL injection vulnerabilities, insecure file uploads, and inefficient database queries. To avoid these pitfalls and follow best practices, developers can refer to resources such as the PHP manual, online tutorials, and community forums for guidance and tips on secure coding practices.

// Example of secure database query using prepared statements to prevent SQL injection

// Establish a database connection
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');

// Prepare a SQL statement with placeholders for user input
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');

// Bind the user input to the placeholders
$stmt->bindParam(':username', $_POST['username']);

// Execute the query
$stmt->execute();

// Fetch the results
$results = $stmt->fetchAll();