这个问题已经在这里有一个答案:
- 使用PHP交互shell 8个回答
我希望能够让一个PHP程序等待用户的输入。 例如:
- 脚本请求授权码从服务器(此代码将通过电子邮件发送)
- 脚本等待用户输入授权码
- 脚本继续
我应该怎么做第2步? (可能吗?)
这个问题已经在这里有一个答案:
我希望能够让一个PHP程序等待用户的输入。 例如:
我应该怎么做第2步? (可能吗?)
The php man page for the cli has a comment here detailing a solution, (copied here for anyone else looking)
<?php
echo "Are you sure you want to do this? Type 'yes' to continue: ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
if(trim($line) != 'yes'){
echo "ABORTING!\n";
exit;
}
fclose($handle);
echo "\n";
echo "Thank you, continuing...\n";
?>