Hi,

I can't believe I'm having this problem, it seems as if this function has it in for me. For some reason, when I use file_get_contents with URLs that have parameters (i.e. ?var1=xx&var2=yy....) doesn't work.

It appears that file_get_contents only accepts the first URL parameter. Has anyone else experienced this? Does anyone know how I can read URLs with parameters from within a PHP script?

Thanks..

    bpat1434 wrote:

    [man]fopen/man and [man]fread/man?

    Hi,

    What do you mean by that?
    Does anyone please have any idea what is going on?

    Thanks

      did you follow the links? It pretty-much explains it and how to use it...

      [man]file_get_contents/man does not just take the base URL as its parameter. You can use dynamic URLs (as my example below illustrates). [man]fopen/man and [man]fread/man can do exactly what file_get_contents does, but in a few more lines.

      Example

      $fcont = file_get_contents('http://www.google.com/search?hl=en&q=bpatterson&btnG=Google+Search');
      $focont = '';
      
      $fp = fopen('http://www.google.com/search?hl=en&q=bpatterson&btnG=Google+Search', "r");
      while(!feof($fp))
      {
      	$focont .= fread($fp, 8192);
      }
      fclose($fp);

      If you echo both of those strings ($fcont and $focont) it gives the proper output of a google search.... so they both do work, the possibility is in your PHP setup, and using urls in the file_get_contents with urls...

      Read the manual as it gives work arounds too

        Write a Reply...