Home php How to execute Get Query by PHP?

How to execute Get Query by PHP?

Author

Date

Category

How to make a GET request to PHP? Let’s say I need to make such a request:

index.php? host = [host] & amp; port = [port]

How to realize such a request? And then I’m not trying, the request does not go out.


Answer 1, Authority 100%

the most stupid and not the most correct way.

$ result = file_get_contents ('http: //host.tld/index.php? host = [Host] & amp ; port = [port] ');

If you suddenly come together to call the site on which this script is located, I propose to discuss here the need for this action.


Answer 2, Authority 300%

If the extension is available PHP-CURL , you can send a request so

$ curl = curl_init ();
CURL_SETOPT ($ CURL, CURLOPT_URL, 'http://httpbin.org/get?qwe=rty& ;=qqq');
CURL_SETOPT ($ CURL, CURLOPT_RETURNTRANSFER, TRUE);
$ Out = CURL_EXEC ($ CURL);
CURL_CLOSE ($ CURL);
Echo $ Out;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions