PHP在命令行下和用户输入交互


function confirm($msg, $expert='yes|y') {
	$input = propmt($msg);
	return in_array(trim($input), explode('|',$expert));
}

function propmt($msg) {
	echo $msg;
	$handle = fopen("php://stdin","r");
	return fgets($handle);
}

if ( confirm('are you sure? (yes/no)') ) {
    echo 'delete!';
}

7 评论

  1. Pingback: cheap NBA 2K17 MT
  2. Pingback: buy nba 2k17 mt
  3. Pingback: UPAlbion.com
  4. Pingback: nba2k16store
  5. Pingback: u4fifa reviews
  6. Pingback: NBA 2K16 MT Coins
  7. Pingback: fut16coin

发表评论