从浏览器中的1个PHP脚本执行多个PHP脚本

the situation is like this. I have created multiple php files with the name operation.php and is hosted in my domains. Something like this:

  1. example.com/operation.php
  2. example123.com/operation.php
  3. example1234.com/operation.php

Okay so now what I want is to code 1 single PHP script that will be the mother of all these operation.php scripts. Something like if I execute motherexample.com/operaterun.php from my browser then all these php scripts will run one by one.

Is this possible? Will this result in server outage? I do not want to run all these at once, maybe take a gap of 10seconds between each script execution.

Need help!

UPDATE I'm not sure whether you Guys are getting it or not but here's another example.. Let's say you have 100 sites each having maintenance.php located at example001.com/maintenance.php now it is not possible to load and run each of those 100 maintenance.php in the browser one by one. So this is why I want 1 single mother-maintenance.php that when run from the browser will execute each of those maintenance.php one by one or maybe with some time gap!

You need to run something like a wget call from the mother motherexample.com/operaterun.php. wget is for linux, if you are using a windows domain check for alternatives example

wget http://example.com/operation.php
wget http://example123.com/operation.php
wget http://example1234.com/operation.php

If a user is doing it, I will recommend AJAX. Otherwise you can try a code like that.

<?php
$somearg = escapeshellarg('blah');
exec("php file2.php $somearg > /dev/null &");

Found on (https://stackoverflow.com/a/1110260/4268741)

However you need to make some changes to it to get it work on your project.

You can use AJAX request. Just make request from your mother script to child pages.

Or you can use simple way - use iframe for each child. If you have 100 child pages then just generate on mother page 100 iframe with src to child. Or you can create this iframe by javascript and add it to page. Then you can make delay between requests.

I think file_get_contents can help you:

<?php
//index.php
set_time_limit(0);

$op_list = array(
    "example.com/operation.php",
    "example123.com/operation.php",
    "example1234.com/operation.php",
);

$opts = array(
    "http" => array(
        "method" => "get",
        "timeout" => 60,
        )
);

$context = stream_context_create($opts);

foreach($op_list as $key => $value)
{
    if($response = file_get_contents($value, null, $context))
    {
        $json_decode = json_decode($response, true);

        echo "{$value}: time_start: {$json_decode['time_start']}, time_end: {$json_decode['time_end']} <br />";
    }
    else
    {
        echo "{$value}: fail <br />";
    }
}

?>

Here is a complete example:

http://try.valinv.com/php/21a6092d20601c77982f7c1ec6b2cc23.html