user2305560
user2305560

Reputation: 23

How to exec external script

Hello i want to ask how to exec external php script with exec() which is not located on my website Does it work like this ?

exec("php http://site.com/executor.php?something=1&something2=A");

Upvotes: 0

Views: 79

Answers (1)

PurkkaKoodari
PurkkaKoodari

Reputation: 6809

No, because when using HTTP the remote server sends the result of the PHP script. The command doesn't support URLs just because of that. If you want to execute the code on the remote server you need to have access to the PHP file itself. If you just need the result, you can use e.g.

readfile("http://site.com/executor.php?something=1&something2=A")

or other ways to read from URLs (fopen and fread, file_get_contents, file...).

Upvotes: 1

Related Questions