views:

28

answers:

1

Im trying to use file_get_contents to get contents of a file and delete a certain part of a line in that file.

Is the following anywhere near what I want to achieve?

 $page = file_get_contents('myPage.php?id='.$_GET['id']);
 $file = 'temp/form_'.$_GET['id'].'.html';
 $change = file_get_contents('myPage.php?id='.$_GET['id']);
 $change = str_replace("/Elements/", "", $change);
 file_put_contents($page, $file);

many thanks

Rifki

+1  A: 
$page = file_get_contents('myPage.php?id='.$_GET['id']);

This gets the contents of the file myPage.php?id=... in the current directory. Since this looks like a part of an URL, you probably want to retrieve some webpage with this statement. If that is the case, you need to use the full URL.

$change = file_get_contents('myPage.php?id='.$_GET['id']);

This again gets the same file as in line 1. You could use $page instead of $change and leave this line out, like this:

$change = str_replace("/Elements/", "", $page);

The function file_put_contents has the filename as first parameter, and the data as second parameter. You have it the other way around.

Sjoerd
Your help is appreciated, thanksRifki
Rifki