What are some potential pitfalls when using RCON commands in PHP for game servers?

One potential pitfall when using RCON commands in PHP for game servers is not properly sanitizing user input, which can lead to security vulnerabilities such as command injection attacks. To mitigate this risk, always validate and sanitize user input before sending it as an RCON command.

// Sanitize user input before sending it as an RCON command
$user_input = filter_var($_POST['user_input'], FILTER_SANITIZE_STRING);

// Send sanitized input as an RCON command
$rcon->sendCommand($user_input);