0

I've been told (from a previous question of mine) that to run an external PHP script, i could use exec or curl.

I've started looking into exec and it seems simple, however I believe I am doing something incorrectly.

Is this not the correct, simple way to just run a page (and not require any data returned)?

exec("/folder/some_page.php?var=" . defined_variable);

I've tried different combinations of relative and direct links, with/without starting with a slash.

Thanks everyone!

4

2 に答える 2

2

exec() runs a program, not a script. In your case, you'd need to call the php executable and pass it the path to the folder on the server. You'd also have to use the command line syntax for passing query parameters, not the URL syntax.

See here for more details on command-line PHP usage (which is what exec() is essentially doing, minus the interactive component): http://php.net/manual/en/features.commandline.php

于 2012-11-26T01:35:34.997 に答える
2

Execute the php:

exec("/folder/some_page.php $var1 $var2 $var3 $varn");

Get the variables in some_page.php:

$var1=$argv[1];
$var2=$argv[2];
$var3=$argv[3];
$var4=$argv[n];
于 2013-11-28T22:13:36.920 に答える