What potential issues could arise from concatenating variables in PHP?

When concatenating variables in PHP, one potential issue that could arise is the lack of proper data sanitization, which could lead to security vulnerabilities such as SQL injection or cross-site scripting attacks. To solve this issue, it is recommended to use prepared statements or escaping functions to properly sanitize the input data before concatenating it.

// Example of using prepared statements to concatenate variables safely
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username, PDO::PARAM_STR);
$stmt->execute();