Heim  >  Artikel  >  Backend-Entwicklung  >  php基于命令行的扩展Readline

php基于命令行的扩展Readline

伊谢尔伦
伊谢尔伦Original
2016-11-22 09:48:382880Durchsuche

简介

readline 扩展函数实现了访问 GNU Readline 库的接口. 这些函数提供了可编辑的命令行. 一个例子是在 Bash 中允许你使用箭头按键来插入字符或者翻看历史命令. 因为这个库的交互特性,这个功能在你写的 Web 程序中没多大用处, 但是当你写的脚本被用在命令行中时非常有用.

安装配置

如果要使用 readline 函数,你必须安装 libreadline,你也能使用非 GPL 的 libedit 库来替代 readline 库。

要使用这些函数,你必须在编译 PHP 的 CGI 或者 CLI 版本时启用 readline 支持. 你需要在编译配置 PHP 时使用 --with-readline[=DIR] 选项. 如果你想使用 libedit 来代替 readline , 配置 PHP 时使用 --with-libedit[=DIR] 选项

相关函数

readline_add_history — 添加一行命令行历史记录

readline_callback_handler_install — 初始化一个 readline 回调接口,然后终端输出提示信息并立即返回

readline_callback_handler_remove — 移除上一个安装的回调函数句柄并且恢复终端设置

readline_callback_read_char — 当一个行被接收时读取一个字符并且通知 readline 调用回调函数

readline_clear_history — 清除历史

readline_completion_function — 注册一个完成函数

readline_info — 获取/设置readline内部的各个变量

readline_list_history — 获取命令历史列表

readline_on_new_line — 通知readline将光标移动到新行

readline_read_history — 读取命令历史

readline_redisplay — 重绘显示区

readline_write_history — 写入历史记录

readline — 读取一行


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP设计模式之命令模式Nächster Artikel:php选项和配置信息