라이브러리
[PHP] readline_read_history - 기록을 읽습니다
PHP에서 readline_read_history 함수 소개
PHP의 readline_read_history 함수는 readline 모듈의 기능 중 하나로, 이전에 입력한 명령어를 저장하고, 다음에 입력할 때 자동으로 추천해주는 기능을 제공합니다. 이 함수는 PHP 7.2 이상에서 사용할 수 있습니다.
readline_read_history 함수의 사용법
readline_read_history 함수는 다음과 같은 형식으로 사용할 수 있습니다.
#hostingforum.kr
php
readline_read_history($filename);
- `$filename` : 이전에 입력한 명령어를 저장할 파일 이름입니다.
예제
다음 예제는 readline_read_history 함수를 사용하여 이전에 입력한 명령어를 저장하고, 다음에 입력할 때 자동으로 추천해주는 기능을 제공합니다.
#hostingforum.kr
php
<?php
// readline_read_history 함수를 사용하여 이전에 입력한 명령어를 저장할 파일 이름을 지정합니다.
$filename = 'history.txt';
// readline_read_history 함수를 호출하여 이전에 입력한 명령어를 저장합니다.
readline_read_history($filename);
// readline_add_history 함수를 사용하여 현재 입력한 명령어를 저장합니다.
readline_add_history('hello');
// readline_read_history 함수를 호출하여 이전에 입력한 명령어를 저장합니다.
readline_read_history($filename);
// readline_completion_function 함수를 사용하여 자동 추천 기능을 제공합니다.
function readline_completion_function($text, $state) {
// 자동 추천 기능을 제공하는 코드를 작성합니다.
// 예를 들어, 'h'를 입력했을 때 'hello', 'help'를 자동으로 추천합니다.
if ($text == 'h') {
return array('hello', 'help');
}
}
// readline_completion_function 함수를 등록합니다.
readline_completion_function = 'readline_completion_function';
// readline_read_history 함수를 호출하여 이전에 입력한 명령어를 저장합니다.
readline_read_history($filename);
// readline_add_history 함수를 사용하여 현재 입력한 명령어를 저장합니다.
readline_add_history('world');
// readline_read_history 함수를 호출하여 이전에 입력한 명령어를 저장합니다.
readline_read_history($filename);
// readline_completion_function 함수를 사용하여 자동 추천 기능을 제공합니다.
echo readline($text = 'h');
?>
readline_read_history 함수의 장점
readline_read_history 함수를 사용하면, 이전에 입력한 명령어를 저장하고, 다음에 입력할 때 자동으로 추천해주는 기능을 제공할 수 있습니다. 이 함수는 PHP 7.2 이상에서 사용할 수 있습니다.
readline_read_history 함수의 단점
readline_read_history 함수를 사용하면, 이전에 입력한 명령어를 저장하는 파일이 생성됩니다. 이 파일은 사용자가 삭제하거나 수정할 수 있습니다. 또한, readline_read_history 함수를 사용하면, 자동 추천 기능이 제공되기 때문에, 사용자가 이전에 입력한 명령어를 기억하지 않아도 됩니다.
결론
readline_read_history 함수는 PHP의 readline 모듈의 기능 중 하나로, 이전에 입력한 명령어를 저장하고, 다음에 입력할 때 자동으로 추천해주는 기능을 제공합니다. 이 함수는 PHP 7.2 이상에서 사용할 수 있습니다. readline_read_history 함수를 사용하면, 이전에 입력한 명령어를 저장하고, 다음에 입력할 때 자동으로 추천해주는 기능을 제공할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.