I need to download files from many web servers and then do somethigs. Some files are big. Each downloads it's independent from another so I want to do in parallel.
So I write the following scripts:
test.php
$urls = [
'url1', 'url2', 'url3'
];
foreach($urls as $url){
popen("php download.php --url=" . $url, "w");
}
download.php
$options = getopt(null, ["url:"]);
$url = $options["url"];
// do somethings - This loop is just for testing purposes
for($i = 0; $i <= 1000000000; $i++){
$i;
}
print parse_url($url)["host"];
When i run php test.php
console show me a sequencial output. What am I doing wrong?