Call to undefined function readline()

When i try to write
$choice = readline();
it shows me

Fatal error: Uncaught Error: Call to undefined function readline()

But for other readlines, like $title = readline("Enter title: ") it doesn’t show me errors. What is the cause? I’m using php version 8.4.0

How can i fix it without needing to write longer codes (if possible) ?

I tried to make a do..while loop where there are multiple choices – cases, but it doesn’t seem to like it

do {
    echo "nn";
    echo "1 - show all booksn";
    echo "2 - show a bookn";
    echo "3 - add a bookn";
    echo "4 - delete a bookn";
    echo "5 - quitnn";
    $choice = readline();

    switch ($choice) {
        case 1:
            foreach ($books as $id => $book) {
                displayBook($id, $book);
            }

            break;
        case 2:
            $id = readline("Enter book id: ");
            displayBook($id, $books[$id]);

            break;
        case 3:
            addBook($books);
            break;
        case 4:
            deleteBook($books);
            break;
        case 5:
            echo "Goodbye!n";
            $continue = false;
            break;
        case 13:
            print_r($books); // hidden option to see full $books content
            break;
        default:
            echo "Invalid choicen";
    };

} while ($continue == true);