What are some potential pitfalls when using PHP for online calculations?

One potential pitfall when using PHP for online calculations is the risk of injection attacks if user input is not properly sanitized. To prevent this, always validate and sanitize user input before using it in calculations to avoid malicious code execution.

// Sanitize user input before using it in calculations
$user_input = $_POST['user_input'];
$sanitized_input = filter_var($user_input, FILTER_SANITIZE_NUMBER_FLOAT);

// Use the sanitized input in calculations
$result = $sanitized_input * 2;

echo $result;