0

My code:

$cc=file_get_contents('http://example.com');
file_put_contents('savefile.htm', $cc);

When I navigate to this address, my browser redirects to 'http://example.com/en/index.htm'. But file_get_contents doesn't recdirect, what can I do?

ReeCube
  • 2,545
  • 17
  • 23
  • 2
    possible duplicate of [How to get the real URL after file\_get\_contents if redirection happens?](http://stackoverflow.com/questions/4323985/how-to-get-the-real-url-after-file-get-contents-if-redirection-happens) – Thomas Ruiz Mar 12 '14 at 10:26

2 Answers2

0
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
chikara
  • 11
  • 1
0

Seems to be a known bug in PHP. See: https://bugs.php.net/bug.php?id=53018

But you can use cURL instead. See http://www.jonasjohn.de/snippets/php/curl-example.htm for some example.

Tobias
  • 81
  • 3