问题
One of the improvements in PHP7.1 is that in Windows the readline extension is available out of the box. I'm having trouble using all of the functions though, as they don't all exist. The following code:
$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;
}
...produces the following output:
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
I can't find any reference in the PHP manual that only a subset of the readline extension's functions are available in Windows.
When I call php_info()
, I get the following output:
readline
Readline Support enabled
Readline library WinEditLine
Is there some php.ini configuration setting (or CLI argument) that needs to be made in order to make all functions available? Alternately, is there some other way of making functions such as readline_callback_handler_install()
available in Windows, or is the extension only half-baked?
回答1:
Initially I thought that you might have been somehow falling through to an ancient PHP 5.0 which lacks those functions, but failing that I would have to guess that your PHP binary was compiled against an underlying library [or version thereof] that doesn't support the feature that those functions depend on.
Cross-referencing the list of functions that are missing with 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: Whoever compiled your PHP needs to figure it out. [probably]
来源:https://stackoverflow.com/questions/50183453/php-7-1-windows-readline-extension-not-all-functions-exist