Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php';首席执行官_Php_Unix_Curl_Exec - Fatal编程技术网

如何使用php';首席执行官

如何使用php';首席执行官,php,unix,curl,exec,Php,Unix,Curl,Exec,我在用exec做卷发。问题在于这两个方面: exec("curl --insecure https://site.com/?term=last day&x=1"); 及 给我一个错误,因为“term”参数中没有合适的字符串。如果我只去一天&x=1,它工作得很好,但显然%20并没有转化为其末端的空格 我认为在curl中把空格放进URL是有问题的。最简单的方法是什么?您需要使用escapeshellarg(): exec()在内部启动一个shell,如果不正确转义字符,shell可能会扩展

我在用exec做卷发。问题在于这两个方面:

exec("curl --insecure https://site.com/?term=last day&x=1");

给我一个错误,因为“term”参数中没有合适的字符串。如果我只去一天&x=1,它工作得很好,但显然%20并没有转化为其末端的空格


我认为在curl中把空格放进URL是有问题的。最简单的方法是什么?

您需要使用
escapeshellarg()


exec()
在内部启动一个shell,如果不正确转义字符,shell可能会扩展字符串中的元字符,如
&

为什么不使用?尝试使用
+
代替。您可以在浏览器中执行此操作,因为浏览器在后台对其进行了正确编码。卷发不能做这样的握手动作。另外,在这样的命令参数中不能有空格。穆萨,谢谢!我不知道为什么我没有想到!
exec("curl --insecure https://site.com/?term=last%20day&x=1");
exec('curl --insecure ' . escapeshellarg($url));