PHP- Call a querystring with json answer

on server 1 I have a PHP script with json output. I call this script with an querysting to get the result.
I want to call this PHP script from another PHP script by calling the commandline.
So I want to call from the PHP script of server one the script on server 2 by calling this$x&license=$x&email=$x

How can I do this?
Ingo FoersterProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
file_get_contents should do it.
$newdata = file_get_contents('$x&license=$x&email=$x');
echo $homepage;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
If the PHP script responds to a GET request (ie, you can type all of the arguments you need into a browser address bar and "visit" the script to get the JSON string back in the browser) then Dave Baldwin's answer is the right way to go.  Note that he recommended the entire URL starting with http:// because you want the script to get processed through the web server.  This is not the same as reading the script locally.  If it gets parsed through the web server, PHP will be invoked and the script's output data will be returned.  If you read it locally, the script will be returned, not its output.

If you try Dave's solution and still have troubles, please post the PHP script that you're trying to call and we can look for an alternative method (probably cURL).
Ingo FoersterProgrammerAuthor Commented:
Works great.
Dave BaldwinFixer of ProblemsCommented:
Glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.