我需要以正确的顺序运行几个 PHP 脚本(它们通过 OAuth 解析和检索一些数据),一个后一个,等待前一个完成( script2需要在 script1 之后解析数据等等......)。
例如:
script1.php -> COMPLETED -> script2-php -> COMPLETED -> script3.php -> ....
我mainscript.php
使用以下代码调用脚本:
<?php
echo '<br /><br />SCRIPT 1<br /><br /> ';
include ("script1.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 2<br /><br />';
include ("script2.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 3<br /><br /> ';
include ("script3.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 4<br /><br /> ';
include ("script4.php");
?>
set_time_limit
所以我的问题是:将and sleep 放入mainscript.php
,或者INCLUDE
函数以正确的顺序依次调用每个脚本是否有意义?你能提供一个解决方案,一个建议吗?