I just noticed that all readline functions are available with my php.exe (PHP 7, Cygwin) except for this one. It would be nice to have it so duplicate lines can be screened.
So to emulate it, I keep a working copy of the history in an array (yeah, extra code/data, but there are ways to keep the history from getting too large).
Loading is like:
<?php
readline_read_history(HISTFILE);
$hist = file(HISTFILE,FILE_IGNORE_NEW_LINES);
array_shift($hist);
?>
Adding is like:
<?php
if (!in_array($line,$hist)) {
$hist[] = $line;
readline_add_history($line);
}
?>
(One may want to just check the last entry being the same.)
PHP.mk документација
readline_list_history
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
function.readline-list-history.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
function.readline-list-history.php
readline_list_history
Референца за `function.readline-list-history.php` со подобрена типографија и навигација.
readline_list_history
(PHP 4, PHP 5, PHP 7, PHP 8)
readline_list_history — Ги прикажува историјата
Параметри
Оваа функција нема параметри.
Вратени вредности
Враќа низа од целата историја на командната линија. Елементите се индексирани со цели броеви почнувајќи од нула.
Белешки од корисници 2 забелешки
dschnepper at box dot com ¶
пред 9 години
Анонимен ¶
пред 15 години
Note this function is only available when PHP is compiled with libreadline, not if it is compiled with libedit.
<?php
if (function_exists('readline_list_history')) {
$history = readline_list_history();
// ...
} else {
echo 'Not supported by the compiled library.'.PHP_EOL;
}
?>