''debecated:parse_str():在没有结果参数的情况下调用parse_str()在“

发布于 2025-01-25 13:24:08 字数 635 浏览 2 评论 0原文

我想使用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);

and;

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

错误:注意:未定义的索引:postid in ..

I want to run the following command with exec but I am getting an error. So what should I use instead?

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

Error:

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

I tried this:

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

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

and;

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

Error: Notice: Undefined index: postID in..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难得心□动 2025-02-01 13:24:08

您不能将整个数组替换为字符串。使用umpode()将数组转换为带有定界符的字符串。

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

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

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

You can't substitute an entire array into a string. Use implode() to convert an array into a string with a delimiter between the values.

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

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

exec("php /var/.../../example.php -- {$arguments}");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文