How can PHP be used to dynamically display prices on a webpage based on user input?

To dynamically display prices on a webpage based on user input, you can use PHP to retrieve the user input, perform any necessary calculations, and then display the updated price on the webpage.

<?php
// Retrieve user input
$userInput = $_POST['user_input'];

// Perform calculations based on user input
if ($userInput == 'option1') {
    $price = 10.00;
} elseif ($userInput == 'option2') {
    $price = 20.00;
} else {
    $price = 0.00;
}

// Display the updated price on the webpage
echo "Price: $" . $price;
?>