"Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in"

"Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in"

我想 运行 使用 exec 命令执行以下命令,但出现错误。那我应该用什么呢?

 php /var/.../../example.php -- 123456789 exampleData1 exampleData2

错误:

Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in /var/.../../example.php on line X

我试过这个:

$argumentsArray = [
    'postID' => 123456
    'foo' => 'bar'
];

exec(php /var/.../../example.php -- $argumentsArray);

和;

 parse_str(parse_url($argv[0], PHP_URL_QUERY),$arguments);
 $postID = $arguments['postID'];

错误:Notice: Undefined index: postID in..

您不能将整个数组替换为字符串。使用 implode() 将数组转换为字符串,值之间有分隔符。

$argumentsArray = [
    'postID' => 123456
    'foo' => 'bar'
];

$arguments = implode(' ', $argumentsArray);

exec("php /var/.../../example.php -- {$arguments}");