I am trying to figure out how to run a parallel execution of a script on the same server. As it is now I am using cUrl, but am not sure this is the best or smartest way to do so. I want, when my primary php script is running, to be able to execute another script with data from primary script but without the primary script to be waiting on the other script,as if I included it. I am prohibited to use javascript or jQuery to run some ajax, so what i have come up with was the cUrl solution... But is this the right way to do so when the 2 scripts are on the same server?
Here is an example of my curl:
$data = array("username" => "$get_username"
,"password" => "$md5_pass"
,"sqlId" => (int)$userid
,"appversion" => (int)$get_version
,"proversion" => (int)0
);
$url = "http://myserver.com/secondscript.php";
$ch = curl_init( $url );
# Setup request to send json via POST.
$payload = json_encode( array("action" => "newUser", "player" => $userid, "json" => $data ));
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
Hoping for help or/and guidance in this matter.
Thanks in advance :-)