How can conditional statements be used to handle user input in PHP scripts run in the console?

When running PHP scripts in the console, we can use conditional statements to handle user input by checking the values provided by the user and executing different blocks of code based on those values. This allows us to create interactive scripts that respond dynamically to user input.

<?php
// Get user input from the console
$input = readline("Enter a value: ");

// Check the user input and execute different blocks of code based on the value
if ($input == "hello") {
    echo "You entered 'hello'.\n";
} elseif ($input == "world") {
    echo "You entered 'world'.\n";
} else {
    echo "You entered something else.\n";
}
?>