PHP数据流应用的一个简单实例
程序员文章站
2023-12-03 23:45:34
复制代码 代码如下:
<?php
$count = 5;
start:
if($count < 5) echo "you can try {$count} time, ";
echo "put password: ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
if(trim($line) != '123456'){
$count--;
if(!$count) goto error;
goto start;
}
goto success;
error:
echo "please try after 1 hour!";
goto out;
success:
echo "logined!";
out:
?>
执行结果:
复制代码 代码如下:
<?php
$count = 5;
start:
if($count < 5) echo "you can try {$count} time, ";
echo "put password: ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
if(trim($line) != '123456'){
$count--;
if(!$count) goto error;
goto start;
}
goto success;
error:
echo "please try after 1 hour!";
goto out;
success:
echo "logined!";
out:
?>
执行结果: