我想用 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..
uj5u.com熱心網友回復:
您不能將整個陣列替換為字串。用于implode()將陣列轉換為值之間有分隔符的字串。
$argumentsArray = [
'postID' => 123456
'foo' => 'bar'
];
$arguments = implode(' ', $argumentsArray);
exec("php /var/.../../example.php -- {$arguments}");
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/471952.html
下一篇:URL中的“ac”是什么意思?
