PHP 7.1+ Windows readline 扩展并非所有功能都存在
PHP 7.1+ Windows readline extension not all functions exist
PHP7.1 中的一项改进是 Windows 中的 readline 扩展是开箱即用的。不过,我在使用所有功能时遇到了麻烦,因为它们并不全部存在。以下代码:
$functions = [
'readline_add_history',
'readline_callback_handler_install',
'readline_callback_handler_remove',
'readline_callback_read_char',
'readline_clear_history',
'readline_completion_function',
'readline_info',
'readline_list_history',
'readline_on_new_line',
'readline_read_history',
'readline_redisplay',
'readline_write_history',
'readline'
];
foreach($functions as $function) {
echo $function . (function_exists($function) ? ' exists' : ' does not exist') . PHP_EOL;
}
...产生以下输出:
readline_add_history exists
readline_callback_handler_install does not exist
readline_callback_handler_remove does not exist
readline_callback_read_char does not exist
readline_clear_history exists
readline_completion_function exists
readline_info exists
readline_list_history does not exist
readline_on_new_line does not exist
readline_read_history exists
readline_redisplay does not exist
readline_write_history exists
readline exists
我在 PHP manual 中找不到任何参考资料,表明在 Windows 中只有一部分 readline 扩展功能可用。
当我调用 php_info()
时,我得到以下输出:
readline
Readline Support enabled
Readline library WinEditLine
是否需要进行一些 php.ini 配置设置(或 CLI 参数)才能使所有功能可用?或者,是否有其他方法可以使 readline_callback_handler_install()
等功能在 Windows 中可用,或者扩展只是半生不熟?
最初我认为您可能会以某种方式掉入缺少这些功能的古老 PHP 5.0,但如果失败,我将不得不猜测您的 PHP 二进制文件是针对底层库 [或其版本] 不支持这些函数所依赖的特性。
交叉引用 ext/readline/readline.c
I would guess you're missing features corresponding to the constants/features HAVE_RL_CALLBACK_READ_CHAR
and HAVE_LIBEDIT
defined in ext/readline/config.m4
缺少的函数列表。
TL;DR:编译您的 PHP 的人需要弄清楚。 [大概]
备案
PHP >= 7.4 到 8.1
是:
- readline_add_history
- readline_clear_history
- readline_completion_function
- readline_info
- readline_list_history
- readline_read_history
- readline_write_history
- 阅读线
否:
- readline_callback_handler_install
- readline_callback_handler_remove
- readline_callback_read_char
- readline_on_new_line
- readline_redisplay
readline_list_history 是在版本 7.2 和 7.3
期间添加的
PHP7.1 中的一项改进是 Windows 中的 readline 扩展是开箱即用的。不过,我在使用所有功能时遇到了麻烦,因为它们并不全部存在。以下代码:
$functions = [
'readline_add_history',
'readline_callback_handler_install',
'readline_callback_handler_remove',
'readline_callback_read_char',
'readline_clear_history',
'readline_completion_function',
'readline_info',
'readline_list_history',
'readline_on_new_line',
'readline_read_history',
'readline_redisplay',
'readline_write_history',
'readline'
];
foreach($functions as $function) {
echo $function . (function_exists($function) ? ' exists' : ' does not exist') . PHP_EOL;
}
...产生以下输出:
readline_add_history exists
readline_callback_handler_install does not exist
readline_callback_handler_remove does not exist
readline_callback_read_char does not exist
readline_clear_history exists
readline_completion_function exists
readline_info exists
readline_list_history does not exist
readline_on_new_line does not exist
readline_read_history exists
readline_redisplay does not exist
readline_write_history exists
readline exists
我在 PHP manual 中找不到任何参考资料,表明在 Windows 中只有一部分 readline 扩展功能可用。
当我调用 php_info()
时,我得到以下输出:
readline
Readline Support enabled
Readline library WinEditLine
是否需要进行一些 php.ini 配置设置(或 CLI 参数)才能使所有功能可用?或者,是否有其他方法可以使 readline_callback_handler_install()
等功能在 Windows 中可用,或者扩展只是半生不熟?
最初我认为您可能会以某种方式掉入缺少这些功能的古老 PHP 5.0,但如果失败,我将不得不猜测您的 PHP 二进制文件是针对底层库 [或其版本] 不支持这些函数所依赖的特性。
交叉引用 ext/readline/readline.c
I would guess you're missing features corresponding to the constants/features HAVE_RL_CALLBACK_READ_CHAR
and HAVE_LIBEDIT
defined in ext/readline/config.m4
缺少的函数列表。
TL;DR:编译您的 PHP 的人需要弄清楚。 [大概]
备案
PHP >= 7.4 到 8.1
是:
- readline_add_history
- readline_clear_history
- readline_completion_function
- readline_info
- readline_list_history
- readline_read_history
- readline_write_history
- 阅读线
否:
- readline_callback_handler_install
- readline_callback_handler_remove
- readline_callback_read_char
- readline_on_new_line
- readline_redisplay
readline_list_history 是在版本 7.2 和 7.3
期间添加的