登录 |

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

2013年11月13日 下午 18:15 | 作者:


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. fut16coin…

    You bet !…

  2. NBA 2K16 MT Coins…

    I’ll fix it!…

  3. u4fifa reviews…

    I was thinking if after work we could grab a cup of coffee…

  4. nba2k16store…

    Take my word ….

  5. UPAlbion.com…

    The youre really talented ….

  6. buy nba 2k17 mt

    it is a very good weblog and that i like it very much!

  7. cheap NBA 2K17 MT

    Too bad we have to return them .

发表评论

您必须登陆才可以发表评论