-1
我想运行php脚本并将参数传递给它。参数在数组中。将数组传递给php脚本
我json_encode数组:
$bot = array(
'timing' => '* * * * *',
'path' => '/sompath/'
);
$bot = json_encode($bot);
并将其发送给脚本:
exec('nohup php script.php "' . $bot . '" > /bot.log 2>&1 &');
但随后,在剧本,我不接收参数:
print_r($argv[1]); // {path:/sompath/,frequency:*
看起来特别像星号这样的符号不会被解析并破坏JSON。
如何将数组传递给另一个脚本并确保所有参数都保留?
为什么您使用json_encode函数两次? – KarthzDIGI
对不起,例如错误 –