The following piece of code will help capture user input when writing command line php scripts.
function getInput($msg){
fwrite(STDOUT, $msg: );
$varin = trim(fgets(STDIN));
return $varin;
}
http://www.php-trivandrum.org