Created
January 16, 2018 10:05
-
-
Save jotaelesalinas/c532998cdba61419089baaa6bf9990c9 to your computer and use it in GitHub Desktop.
PHP read from console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function read_from_console ($prompt) { | |
if ( function_exists('readline') ) { | |
$line = trim(readline($prompt)); | |
if (!empty($line)) { | |
readline_add_history($line); | |
} | |
} else { | |
echo $prompt; | |
$line = trim(fgets(STDIN)); | |
} | |
return $line; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment