牛牛在线工具

readline_list_history()

收录 8868 个 PHP 函数,含用途说明与用法示例。

readline_list_history()

获取当前 readline 历史记录的列表

函数名:readline_list_history() 适用版本:PHP 5 >= 5.1.0, PHP 7 函数用途:readline_list_history() 函数用于获取当前 readline 历史记录的列表。 语法:array readline_list_history( void ) 参数:无 返回值:返回一个包含当前 readline 历史记录的数组,如果没有历史记录,则返回一个空数组。 示例: // 添加一些历史记录 readline_add_history("First command"); readline_add_history("Second command"); readline_add_history("Third command"); // 获取历史记录列表 $history = readline_list_history(); // 打印历史记录 foreach ($history as $index => $command) { echo "[$index] $command\n"; } 输出: [0] First command [1] Second command [2] Third command 在上面的示例中,我们首先使用 readline_add_history() 函数添加了一些命令到 readline 历史记录中。然后,我们使用 readline_list_history() 函数获取历史记录的列表,并通过 foreach 循环打印出每个历史记录的索引和命令内容。