Created
May 17, 2014 13:01
-
-
Save Khanashima/42a4f589ba3733eb23db to your computer and use it in GitHub Desktop.
PHPで標準入力 ref: http://qiita.com/kiimiiis/items/89ac68e5f7451bf64d1a
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
C:\xampp\htdocs\PhpProject1>php ./single.php | |
1 | |
string(1) "1" |
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
C:\xampp\htdocs\PhpProject1>php ./multi.php | |
1 | |
2 | |
3 | |
テスト | |
5 | |
array(5) { | |
[0]=> | |
string(1) "1" | |
[1]=> | |
string(1) "2" | |
[2]=> | |
string(1) "3" | |
[3]=> | |
string(6) "テスト" | |
[4]=> | |
string(1) "5" | |
} |
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 | |
$stdins = array(); | |
while(true) | |
{ | |
$stdin = trim(fgets(STDIN)); | |
if ($stdin === '') | |
{ | |
var_dump($stdins); | |
return; | |
} | |
$stdins[] = $stdin; | |
} | |
?> |
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 | |
$stdin = trim(fgets(STDIN)); | |
var_dump($stdin); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment