What are some common pitfalls when using PHP for web development?

Common pitfalls when using PHP for web development include insecure coding practices, such as not properly sanitizing user input, which can lead to security vulnerabilities like SQL injection attacks. Another pitfall is not using proper error handling techniques, which can make debugging difficult and lead to unexpected behavior in the application. Additionally, not following coding standards and best practices can make the codebase harder to maintain and understand. To prevent SQL injection attacks, always use prepared statements with parameterized queries when interacting with a database in PHP:

```php
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $username);
$stmt->execute();
```

To improve error handling, use try-catch blocks to catch and handle exceptions gracefully:

```php
try {
    // Code that may throw an exception
} catch (Exception $e) {
    // Handle the exception, log it, and display an error message to the user
    echo 'An error occurred: ' . $e->getMessage();
}
```

To ensure code maintainability, follow coding standards like PSR-1 and PSR-2 and use design patterns like MVC to organize your codebase effectively.