if you have a long script, then split the page using the input parameter for each task. (then each page acts like a stream) if the page has 1 lac product_keywords long process cycle, then instead of a cycle, make logic for one keyword and pass this keyword out of magic or cornjobpage.php (in the following example)
and for the background worker, I think you should try this technique, it will help to name as many pages as you like, all pages will start immediately independently, without expecting each response to the page to be asynchronous.
cornjobpage.php // mainpage
<?php post_async("http://localhost/projectname/testpage.php", "Keywordname=testValue"); //post_async("http://localhost/projectname/testpage.php", "Keywordname=testValue2"); //post_async("http://localhost/projectname/otherpage.php", "Keywordname=anyValue"); //call as many as pages you like all pages will run at once independently without waiting for each page response as asynchronous. ?> <?php /* * Executes a PHP page asynchronously so the current page does not have to wait for it to finish running. * */ function post_async($url,$params) { $post_string = $params; $parts=parse_url($url); $fp = fsockopen($parts['host'], isset($parts['port'])?$parts['port']:80, $errno, $errstr, 30); $out = "GET ".$parts['path']."?$post_string"." HTTP/1.1\r\n";//you can use POST instead of GET if you like $out.= "Host: ".$parts['host']."\r\n"; $out.= "Content-Type: application/x-www-form-urlencoded\r\n"; $out.= "Content-Length: ".strlen($post_string)."\r\n"; $out.= "Connection: Close\r\n\r\n"; fwrite($fp, $out); fclose($fp); } ?>
testpage.php
<? echo $_REQUEST["Keywordname"];
PS: if you want to send the url parameters in a loop, do the following answer: https://stackoverflow.com/a/416829/
Hassan Saeed Dec 19 '16 at 15:32 2016-12-19 15:32
source share