Hello I have code like this:
file1.php:
session_start();
$object1 = new object1($_SESSION['variable']);
switch($_GET['variableGet']){
case 'a': $object2 = new object2(); break;
case 'b': $object2 = new object2(); break;
}
/*
etc etc
*/
file2.php:
require_once('file1.php');
sleep(5);
$object2->doSomethingForFile2();
echo 'file2 is done!';
file3.php:
require_once('file1.php');
sleep(7);
$object2->doSomethingForFile3();
echo 'file 3 is done!';
With AJAX I am calling file2.php and file3.php.
What I want to do:
I want the file2 and file3 start at the same moment.
Problem:
file3 is waiting for file2 -> when file2 is finished (after 5 seconds), then file3 starts script and whole ajax is loading in 12 seconds (sleep(5) + sleep(7)), not in 7 seconds.
Own observations:
This problem depends on *require_once(file1.php)*, which is used in file2 and file3. If i will run code like this:
file2.php:
sleep(5);
echo 'file2 is done!';
file3.php:
sleep(7);
echo 'file 3 is done!';
Whole data loads in 7 seconds (after 5 seconds file2.php and then after 2 seconds file3.php)