If you want to prefill the prompt with something when using readline, this worked for me:
<?php
  function readline_callback($ret)
  {
    global $prompt_answer, $prompt_finished;
    $prompt_answer = $ret;
    $prompt_finished = TRUE;
    readline_callback_handler_remove();
  }
  readline_callback_handler_install('Enter some text> ',
                                    'readline_callback');
  $prefill = 'foobar';
  for ($i = 0; $i < strlen($prefill); $i++)
  {
    readline_info('pending_input', substr($prefill, $i, 1));
    readline_callback_read_char();
  }
  $prompt_finished = FALSE;
  $prompt_answer = FALSE;
  while (!$prompt_finished)
    readline_callback_read_char();
  echo 'You wrote: ' . $prompt_answer . "\n";
?>