note 93598 deleted from function.popen by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 11:16:59 +0000 |
| Subject: | note 93598 deleted from function.popen by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197070@lists.php.net to get a copy of this message | ||
Note Submitter: lwalker at snet dot net
----
To run a php script and not wait for it I use this on windows
$commandString = "start /b c:\\php\\php.EXE c:\\image\\cleanup.php --passaccount=$account
--passcount=$count";
pclose(popen($commandString, 'r'));
Note to pass my script vars you need dashdash.
to read the var use --this is in cleanup.php
<?php
function arguments($argv) {
$_ARG = array();
foreach ($argv as $arg) {
if (ereg('--[a-zA-Z0-9]*=.*',$arg)) {
$str = split("=",$arg); $arg = '';
$key = ereg_replace("--",'',$str[0]);
for ( $i = 1; $i < count($str); $i++ ) {
$arg .= $str[$i];
}
$_ARG[$key] = $arg;
} elseif(ereg('-[a-zA-Z0-9]',$arg)) {
$arg = ereg_replace("-",'',$arg);
$_ARG[$arg] = 'true';
}
}
return $_ARG;
}
sleep(5);
$var_array= arguments($argv);
extract($var_array, EXTR_PREFIX_SAME, "wddx");//$user comes from here
//echo "hello new $user";
$account=$passaccount;
$count=$passcount;
?>