Skip to content

Instantly share code, notes, and snippets.

@aziz-blr
Created August 1, 2017 09:39
Show Gist options
  • Save aziz-blr/13067e67af90aa6aabfd24da52c8f19c to your computer and use it in GitHub Desktop.
Save aziz-blr/13067e67af90aa6aabfd24da52c8f19c to your computer and use it in GitHub Desktop.
Execute php script in background
function execInBackground($cmd){
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}else{
exec($cmd . " > /dev/null &");
}
}
// Pass parameter if you need
//$second_param = 1;
//execInBackground('php E:/aziz/xampp/htdocs/dompdf-example/index.php db_name '.$second_param);
execInBackground('php E:/aziz/xampp/htdocs/dompdf-example/index.php ');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment