<?php
$num = rand ( 1 , 1000 ) ;
for ( ; $num <= 1000 ; ) {
$input = ( int ) fgets ( STDIN ) ;
if ( $input == $num ) {
echo " 正确 " ;
echo " \n " ;
break ;
} elseif ( $input < $num ) {
echo " 小于该数 \n " ;
} elseif ( $input > $num ) {
echo " 大于该数 \n " ;
}
}
(显示猜的次数未写)