Created
July 27, 2015 02:59
-
-
Save tojibon/ea58d87b75b54413a2e7 to your computer and use it in GitHub Desktop.
Getting user data via Console Input with PHP.
This file contains 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
<?php | |
function read ($length='255') | |
{ | |
if (!isset ($GLOBALS['StdinPointer'])) | |
{ | |
$GLOBALS['StdinPointer'] = fopen ("php://stdin","r"); | |
} | |
$line = fgets ($GLOBALS['StdinPointer'],$length); | |
return trim ($line); | |
} | |
echo "Enter your name: "; | |
$name = read (); | |
echo "\nHello $name! Where you came from? "; | |
$where = read (); | |
echo "\nI see. $where is very good place."; | |
//php php-console.php | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment