If only to create a simple GET request to a different script on the different server. How do you do that?

In a single situation, I simply need to request an exterior script without resorting to any output.

make_request('http://world wide web.externalsite.com/script1.php?variable=45') //example usage

Within the second situation, I have to obtain the text output.

$output = make_request('http://world wide web.externalsite.com/script2.php?variable=45')

echo $output //string output

To tell the truth, I don't want to fool around with CURL because this is not truly the job of CURL. I additionally don't want to take advantage of http_get as I don't possess the PECL extensions.

Would fsockopen work? If that's the case, how do you do that without reading through within the items in the file? Can there be not one other way?

Thanks all

Update

I ought to of added, within the first situation, I don't want to wait for a script to come back anything. When I understand file_get_contents() will wait for a page to load fully etc?

file_get_contents is going to do what you would like

$output = file_get_contents('http://world wide web.example.com/')

echo $output

Edit: One method to fire off a GET request and return immediately.

Cited from http://petewarden.typepad.com/searchbrowser/2008/06/how-to-publish-an.html

function curl_publish_async($url, $params)

amplifier$val) publish_params[] = $key.'='.urlencode($val)

    

    $publish_string = implode('&', $publish_params)

    $parts=parse_url($url)

    $fp = fsockopen($parts['host'],

        isset($parts['port'])?$parts['port']:80,

        $errno, $errstr, 30)

    $out = "Publish ".$parts['path']." HTTP/1.1rn"

    $out.= "Host: ".$parts['host']."rn"

    $out.= "Content-Type: application/x-world wide web-form-urlencodedrn"

    $out.= "Content-Length: ".strlen($publish_string)."rn"

    $out.= "Connection: Closernrn"

    if (isset($publish_string)) $out.= $publish_string

    fwrite($fp, $out)

    fclose($fp)



What this may is open a socket, fire off a get request, and immediately close the socket and return.

This is the way to create Marquis' answer use both Publish and obtain demands:

  // $type must equal 'GET' or 'POST'

  function curl_request_async($url, $params, $type='POST')

  amplifier$val) publish_params[] = $key.'='.urlencode($val)

      

      $publish_string = implode('&', $publish_params)

      $parts=parse_url($url)

      $fp = fsockopen($parts['host'],

          isset($parts['port'])?$parts['port']:80,

          $errno, $errstr, 30)

      // Data gets into the road for any GET request

      if('GET' == $type) $parts['path'] .= '?'.$publish_string

      $out = "$type ".$parts['path']." HTTP/1.1rn"

      $out.= "Host: ".$parts['host']."rn"

      $out.= "Content-Type: application/x-world wide web-form-urlencodedrn"

      $out.= "Content-Length: ".strlen($publish_string)."rn"

      $out.= "Connection: Closernrn"

      // Data gets into the request body for any Publish request

      if ('POST' == $type &lifier&lifier isset($publish_string)) $out.= $publish_string

      fwrite($fp, $out)

      fclose($fp)