HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

readline

Description

The readline of Readline for PHP reads a line.

Syntax

readline(
    ?string $prompt = null
): string|false

Parameters

prompt

You may specify a string with which to prompt the user.

Return

Returns a single string from the user. The line returned has the ending newline removed. If there is no more data to read, then false is returned.

Examples

1 · void

<?

$return = readline();

var_export($return);
false

2 · prompt

<?

$prompt = "myprompt";

$return = readline($prompt);

var_export($return);
false

3 · readline_list_history readline_info

<?

for($i = 0; $i < 3; ++$i)
{
    $prompt = "myprompt";

    $return = readline($prompt);

    readline_add_history($return);
}

print_r(readline_list_history());
print_r(readline_info());
Array
(
    [0] => 
    [1] => 
    [2] => 
)
Array
(
    [line_buffer] => 
    [point] => 0
    [end] => 0
    [mark] => 0
    [done] => 1
    [pending_input] => 0
    [prompt] => myprompt
    [terminal_name] => 
    [completion_append_character] =>  
    [completion_suppress_append] => 
    [erase_empty_line] => 0
    [library_version] => 7.0
    [readline_name] => other
    [attempted_completion_over] => 0
)