Why am I unable to use 'readline_on_new_line()' on my windows machine?

php.internals

Unnamed Person

5 years ago
Hello Internals, I am unable to call readline_on_new_line() function. I am posting this to internals to confirm whether it is a bug or an issue with docs. The manual suggests that this function is available on php 8. https://php.net/manual/en/function.readline-on-new-line.php However, when I invoke this in my script, it informs of calling an unknown function. Other readline functions, such as readline(), readline_read_history(), readline_write_history(), do work. I wrote to shell `var_dump(function_exists('readline_on_new_line'));`. It responded with `bool(false)`. I wrote, `var_dump(extension_loaded('readline'))`. It said, `bool(true)`. Note: my PHP version (PHP_VERSION) is 8.0.5. Any type of help will be appreciated. Kind regards Hamza Ahmad

Kalle Sommer Nielsen

5 years ago
Den tor. 29. apr. 2021 kl. 18.50 skrev Hamza Ahmad <office.hamzaahmad@gmail.com>:
> > Hello Internals, > I am unable to call readline_on_new_line() function. > I am posting this to internals to confirm whether it is a bug or an issue > with docs.
Please report such things on the bug tracker first always, so it can be checked there -- that part of why we have a bug tracker, to confirm such things or not.
-- regards, Kalle Sommer Nielsen kalle@php.net

Nikita Popov

5 years ago
On Thu, Apr 29, 2021 at 5:51 PM Hamza Ahmad <office.hamzaahmad@gmail.com> wrote:
> Hello Internals, > I am unable to call readline_on_new_line() function. > I am posting this to internals to confirm whether it is a bug or an issue > with docs. > The manual suggests that this function is available on php 8. > https://php.net/manual/en/function.readline-on-new-line.php > However, when I invoke this in my script, it informs of calling an unknown > function. Other readline functions, such as readline(), > readline_read_history(), readline_write_history(), do work. > I wrote to shell `var_dump(function_exists('readline_on_new_line'));`. It > responded with `bool(false)`. I wrote, > `var_dump(extension_loaded('readline'))`. It said, `bool(true)`. > Note: my PHP version (PHP_VERSION) is 8.0.5. > Any type of help will be appreciated. > Kind regards > Hamza Ahmad >
Hi Hamza, This function is only available if the HAVE_RL_ON_NEW_LINE feature is available. I'm not sure whether the readline version on Windows doesn't support this, or whether the flag just isn't set. Maybe Christoph can comment on that? Nikita

Christoph Becker

5 years ago
On 30.04.2021 at 10:53, Nikita Popov wrote:
> On Thu, Apr 29, 2021 at 5:51 PM Hamza Ahmad <office.hamzaahmad@gmail.com> > wrote: > >> I am unable to call readline_on_new_line() function. >> I am posting this to internals to confirm whether it is a bug or an issue >> with docs. >> The manual suggests that this function is available on php 8. >> https://php.net/manual/en/function.readline-on-new-line.php >> However, when I invoke this in my script, it informs of calling an unknown >> function. Other readline functions, such as readline(), >> readline_read_history(), readline_write_history(), do work. >> I wrote to shell `var_dump(function_exists('readline_on_new_line'));`. It >> responded with `bool(false)`. I wrote, >> `var_dump(extension_loaded('readline'))`. It said, `bool(true)`. >> Note: my PHP version (PHP_VERSION) is 8.0.5. >> Any type of help will be appreciated. > > This function is only available if the HAVE_RL_ON_NEW_LINE feature is > available. I'm not sure whether the readline version on Windows doesn't > support this, or whether the flag just isn't set. Maybe Christoph can > comment on that?
Windows uses wineditline[1], and that library doesn't implement rl_on_new_line(), so the PHP function is not supposed to be available there. I've just updated the docs[2]. [1] <https://github.com/winlibs/wineditline> [2] <https://github.com/php/doc-en/commit/bca9a9e2d971ade48c06e5b2540a0b1e536fca2b>