Computer Programming - 2

<?php

echo "What coat color/ pattern of whippet do you like? Brindle, parti-color, or solid? ";
$fin = fopen ("php://stdin","r");
$line = fgets($fin);
fclose($fin);
$petType = trim(strtolower($line));

switch ($petType) {
 case "brindle":
  echo "I see you like Tiger-striped (brown/tawny with darker streaks).\n";
  break;
 case "parti-color":
  echo "I see you like White broken with solid or brindle patches.\n";
  break;
 case "solid":
  echo "I see you like Black, white, blue, red, or fawn.\n";
  break;
 default:
  echo "That was not one of the three options to choose from.\n";
  break;
}

/*

https://www.w3schools.com/php/
https://www.w3schools.com/php/php_switch.asp
https://stackoverflow.com/questions/6543841/php-cli-getting-input-from-user-and-then-dumping-into-variable-possible

This file is called Demo-PageTwo.php, to run it, in a terminal type: php Demo-PageTwo.php


A sample input and output is:
$ php Demo-PageTwo.php
What coat color/ pattern of whippet do you like? Brindle, parti-color, or solid? solid
I see you like Black, white, blue, red, or fawn.

*/

?>

 

Create Your Own Website With Webador