在运行脚本之前是否可以等待 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;
我希望这是可能的...