readline 扩展函数实现了访问 GNU Readline 库的接口. 这些函数提供了可编辑的命令行. 一个例子是在 Bash 中允许你使用箭头按键来插入字符或者翻看历史命令. 因为这个库的交互特性,这个功能在你写的 Web 程序中没多大用处, 但是当你写的脚本被用在命令行中时非常有用.
安装
要使用这些函数,你必须在编译 PHP 的 CGI 或者 CLI 版本时启用 readline 支持. 你需要在编译配置 PHP 时使用 --with-readline[=DIR] 选项. 如果你想使用 libedit 来代替 readline , 配置 PHP 时使用--with-libedit[=DIR]选项
If you missed that argument when initially installing php5 and want to add it after the fact, this is all you need: sudo apt-get install php5-readline
运行时配置
这些函数的行为受 php.ini 中的设置影响。
名字 | 默认 | 可修改范围 | 更新日志 |
---|---|---|---|
cli.pager | "" | PHP_INI_ALL | 自 PHP 5.4.0 可用. |
cli.prompt | "\ \\> " | PHP_INI_ALL | 自 PHP 5.4.0 可用. |
- cli.pager string:External tool to display output from command line.
- cli.prompt string:命令行 提示.