Created
April 19, 2014 14:53
-
-
Save kadet1090/11086663 to your computer and use it in GitHub Desktop.
If you've ever dreamed about restarting PHP from PHP script - here you go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function restart() { | |
global $argv; | |
$cargs = []; | |
foreach($argv as $arg) | |
$cargs[] = strpos($arg, ' ') !== false ? '"'.$arg.'"' : $arg; | |
if(substr(PHP_OS, 0, 3) == 'WIN') | |
die((new \COM("WScript.Shell"))->Run(PHP_BINARY.' '.implode(' ', $cargs), 0, false)); | |
else | |
die(exec(PHP_BINARY.' '.implode(' ', $cargs).' > /dev/null &')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment