BigMike
BigMike

Reputation: 1093

Run php script remotely

I have a php script (qa.php) that my app points to on my current server. I just recently switched servers and want the qa.php script running from this new server.

Is there a way to have a php script redirect or automatically run the remote php script?

Upvotes: 0

Views: 2563

Answers (1)

Mark Grey
Mark Grey

Reputation: 10257

If you mean a redirect in the sense of a client visiting this page, you can use the header() function to change the location header and simply perform the redirect.

header('Location:http://www.your-new-domain.com/qa.php');

But if you mean (and this I'm assuming) running the script without direct client interaction, there are a few different approaches. One good way is to use the Curl library to send a request formed the way you'd like to the script. I've used this method in scheduling cronjobs before that had to fire signals to several controllers at once and record the output.

http://www.php.net/manual/en/intro.curl.php

It's also acceptable to use the file_get_contents() php function to simulate a client visit on the page if you don't need to manipulate any specific headers for the request going to the server-side script.

Upvotes: 2

Related Questions