<?php
function rl_callback($ret)
{
global $c, $prompting;
echo "您输入了: $ret\n";
$c++;
if ($c > 10) {
$prompting = false;
readline_callback_handler_remove();
} else {
readline_callback_handler_install("[$c] 输入内容: ", 'rl_callback');
}
}
$c = 1;
$prompting = true;
readline_callback_handler_install("[$c] 输入内容: ", 'rl_callback');
while ($prompting) {
$w = NULL;
$e = NULL;
$n = stream_select($r = array(STDIN), $w, $e, null);
if ($n && in_array(STDIN, $r)) {
// 读取一个字符,输入换行符时将调用回调函数
readline_callback_read_char();
}
}
echo "提示已禁用。全部完成。\n";
?>