Note that readline_add_history() will add empty strings too.
<?php
$line = readline(">>> ");
if (!empty($line)) {
readline_add_history($line);
}
?>
(PHP 4, PHP 5, PHP 7)
readline_add_history — 添加一行命令行历史记录
$line
) : bool这个函数添加一行到命令行历史记录 This function adds a line to the command line history.
line
这一行将被添加到历史.
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
Note that readline_add_history() will add empty strings too.
<?php
$line = readline(">>> ");
if (!empty($line)) {
readline_add_history($line);
}
?>