使用 PHP 在 phpvibe 中传递参数 cron 作业文件执行命令
pass parameter cron job file execute command in phpvibe with PHP
我们有这样的源文件:
$binpath = get_option('binpath', '/usr/bin/php');
$command = $binpath . ABSPATH . "/videocron-premium.php plan_id='$plan_id'";
exec("$command > /dev/null &", $arrOutput);
想要将参数发送到此文件
这是我文件的一部分:
parse_str($argv[1], $params);
$plan_id = $params['plan_id'];
我想在此 php cron 文件中获取参数。
这个 parse_str 对我不起作用!
我如何解析 $argv 并继续我的算法
您可以使用此代码获取 plan_id
foreach ($argv as $arg) {
if (stripos($arg, "plan_id") !== false) {
$plan_id = substr($arg, 8);
}
}
我们有这样的源文件:
$binpath = get_option('binpath', '/usr/bin/php');
$command = $binpath . ABSPATH . "/videocron-premium.php plan_id='$plan_id'";
exec("$command > /dev/null &", $arrOutput);
想要将参数发送到此文件
这是我文件的一部分:
parse_str($argv[1], $params);
$plan_id = $params['plan_id'];
我想在此 php cron 文件中获取参数。
这个 parse_str 对我不起作用!
我如何解析 $argv 并继续我的算法
您可以使用此代码获取 plan_id
foreach ($argv as $arg) {
if (stripos($arg, "plan_id") !== false) {
$plan_id = substr($arg, 8);
}
}