Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : GNU Readline : readline_callback_handler_install

readline_callback_handler_install

Initializes the readline callback interface and terminal, prints the prompt and returns immediately (PHP 5 >= 5.1.0)
bool readline_callback_handler_install ( string prompt, callback callback )

Example 2066. Readline Callback Interface Example

<?php
function rl_callback($ret)
{
   global
$c, $prompting;

   echo
"You entered: $ret\n";
   
$c++;

   if (
$c > 10) {
       
$prompting = false;
       
readline_callback_handler_remove();
   } else {
       
readline_callback_handler_install("[$c] Enter something: ", 'rl_callback');
   }
}

$c = 1;
$prompting = true;

readline_callback_handler_install("[$c] Enter something: ", 'rl_callback');

while (
$prompting) {
   
$w = NULL;
   
$e = NULL;
   
$n = stream_select($r = array(STDIN), $w, $e, null);
   if (
$n && in_array(STDIN, $r)) {
       
// read a character, will call the callback when a newline is entered
       
readline_callback_read_char();
   }
}

echo
"Prompting disabled. All done.\n";
?>

Change Language


Follow Navioo On Twitter
readline_add_history
readline_callback_handler_install
readline_callback_handler_remove
readline_callback_read_char
readline_clear_history
readline_completion_function
readline_info
readline_list_history
readline_on_new_line
readline_read_history
readline_redisplay
readline_write_history
readline
eXTReMe Tracker