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('[email protected]', '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?

2 Answers 2

4

The & sign is a special character in the Unix shell. You need to escape it:

exec("wget '$url'");

Also, if your URL is based on user input in any way, be very careful to escape it with escapeshellarg. Otherwise your users will be able to run arbitrary Unix commands on your server.

Sign up to request clarification or add additional context in comments.

Comments

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

you need to qoute the url


& is the sign for putting a task into background

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.