0

我需要以正确的顺序运行几个 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函数以正确的顺序依次调用每个脚本是否有意义?你能提供一个解决方案,一个建议吗?

4

1 回答 1

1

不需要 sleep 命令,php 按照定义按顺序运行它。

include 命令的行为就像您在主 php 文件中按顺序手动添加了包含的 php 文件的行!

于 2013-04-13T10:39:58.200 回答