0

This seems like it would be the most basic thing, maybe so basic that no one bothers to mention it. I've learned all the basic PHP syntax and some functions like fread() and fopen(), but I can't find a good way to download a URL into a string. Right now my best attempt is:

$someFile = fopen("http://www.pastats.com/report/winners?start=1386916400&duration=86400", r);
$someData = fread($someFile, filesize("http://www.pastats.com/report/winners?start=1386916400&duration=86400") );

but it doesn't work because apparently filesize doesn't work if I don't have write permissions. I know there's got to be a really simple way of doing this.

Matt Munson
  • 2,903
  • 5
  • 33
  • 52

1 Answers1

1

Assuming your permissions are set correctly (allow_url_fopen set to true), which it sounds like it is, then file_get_contents() is your best bet. Otherwise you'll want to use PHP's cURL functions.

Community
  • 1
  • 1
Ben D
  • 14,321
  • 3
  • 45
  • 59