Home > Article > Backend Development > PHP command line-based extension Readline
Introduction
The readline extension function implements an interface to access the GNU Readline library. These functions provide an editable command line. An example is in Bash that allows you to use the arrow keys to insert characters or browse command history. Because of this library Interactive feature, this feature is not very useful in the web program you write, but it is very useful when the script you write is used in the command line.
Installation configuration
If you want to use the readline function, you must install libreadline, you It is also possible to use the non-GPL libedit library instead of the readline library.
To use these functions, you must enable readline support when compiling the CGI or CLI version of PHP. You need to use the --with-readline[=DIR] option when compiling and configuring PHP. If you want to use libedit instead of readline, Use the --with-libedit[=DIR] option when configuring PHP
Related functions
readline_add_history — Add a line of command line history
readline_callback_handler_install — Initialize a readline callback interface, then the terminal outputs a prompt message and returns immediately
readline_callback_handler_remove — Remove the last installed callback function handle and restore the terminal settings
readline_callback_read_char — Read a character when a line is received and notify readline to call the callback function
readline_clear_history — Clear history
readline_completion_function — Register a completion function
readline_info - Get/Set the variables inside Readline
Readline_List_history — Get the command history list Play — Rebcing Display Area — Readline_write_history — Writing Enter history
readline — read a line