PHP Simple interactions with Shell
<?
/**
* @author _LameMind <lamemind@gmail.com>
*/
abstract class LinuxSystem {
/**
* @param string $question
* @param array $admittedValues
* @return mixed
*/
public static function askTerminal ($question, $admittedValues = array ("Y" => true, "N" => false)) {
$questionStr = $question . " [" . implode (",", array_keys ($admittedValues)) . "]";
do {
$answer = readline ($questionStr);
}
while (!isset ($admittedValues[ $answer ]));
return $admittedValues[ $answer ];
}
/**
* @param string $message
*/
public static function notifyTerminal ($message) {
readline ($message);
}
}