What are some common security vulnerabilities in PHP that developers should be aware of when building an online shop?

One common security vulnerability in PHP when building an online shop is SQL injection. Developers should use prepared statements with parameterized queries to prevent attackers from executing malicious SQL commands.

// Using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
$stmt->execute();
```

Another common vulnerability is cross-site scripting (XSS). Developers should sanitize user input and encode output to prevent attackers from injecting malicious scripts into web pages.

```php
// Sanitizing user input to prevent XSS
$clean_input = htmlspecialchars($_POST['input'], ENT_QUOTES, 'UTF-8');
```

Lastly, insecure file uploads can also be a security risk. Developers should validate file types, restrict file permissions, and store uploaded files outside the web root directory to prevent attackers from uploading malicious files.

```php
// Validating file type before uploading
$allowed_types = array('jpg', 'jpeg', 'png');
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if (!in_array($extension, $allowed_types)) {
    die('Invalid file type.');
}