我有一个问题,即readline()跳过了一些条目。在下面的示例中,它很简单。
<?php
while(readline()!="stop")
{
echo "You have entered:". readline()."\n";
}
它给了我
1
2
You have entered:2
2
2
You have entered:2
3
3
You have entered:3
t
t
You have entered:t
5
You have entered:
5
5
You have entered:5
stop
Done.
第一次读取停止,其余需要我输入两次。有任何想法吗?感谢
答案 0 :(得分:1)
在你的回声中,你再次调用readline()
,你需要存储第一个值并将其输出到回声...
while(($text = readline())!="stop")
{
echo "You have entered:". $text."\n";
}