0

I'm executing a php function via the PHP exec() function but it seems to only pass through 1 variable at time.

$url = "http://domain.co/test.php?phone=123&msg=testing"
exec('wget '.$url);

Within test.php file I have

$msg = "msg =".$_GET["msg"]." number=".$_GET["phone"];
mail('me@gmail.com', 'Working?', $msg);

I get an email which returns phone variable only.

But if I change the url as follows

$url = "http://domain.co/test.php?msg=testing&phone=123"

I get msg but not phone? Any ideas on what is causing this strange behavior?

4

2 回答 2

4

&符号是 Unix shell 中的一个特殊字符。你需要逃避它:

exec("wget '$url'");

此外,如果您的 URL 以任何方式基于用户输入,请小心使用escapeshellarg. 否则,您的用户将能够在您的服务器上运行任意 Unix 命令。

于 2013-07-17T14:07:11.153 回答
1
$url = "http://domain.co/test.php?phone=123&msg=testing"
exec('wget "'.$url.'"');

你需要引用网址


& 是将任务置于后台的标志

于 2013-07-17T14:07:45.150 回答