是否可以在运行脚本之前等待20秒?
我的意思是我尝试set_time_limit(20)但是当我点击按钮时,它总是运行脚本。
我想时间限制仅仅是脚本运行时的时间限制,然后停止。
我正在寻找一个可以帮助我让我的脚本等待20秒的功能。我知道它可以在jQuery上运行,但我坚持认为是Yii框架。
我有以下示例脚本
$coco = mysql_query( "SELECT * FROM gameWaiting" );
if ( empty( $coco ) ) {
mysql_query( "INSERT INTO gameWaiting VALUE('', '$email', '$language')" );
$status = 0; // IF THE STATUS is equal to 0 means the db was empty so it will insert
// AND WAIT FOR OTHER PLAYER TO INSERT ALSO
} else {
mysql_query( "INSERT INTO gameWaiting VALUE('', '$email', '$language')" );
$status = 1; // IF THE STATUS is equal to 1 means the db was !empty so it will insert also
// BUT THERE is no need to wait for other player otherwise RAND() the user.
}
// NOW SET TIME HERE when it will INSERT to the game
if ( time was equal to set) {
// IF SOMEONE insert into gameWaiting it will create game
mysql_query( "INSERT INTO game VALUE('','name','email','language')" );
} else {
// No player was added
}
echo $status;
我希望这是可能的......