$f = fopen("1.php", "w");
fwrite($f, "<?php // ЧТО ТУТ НУЖНО ВСТАВИТЬ, ЧТОБЫ ПОТОМ В ФАЙЛЕ 1.php БЫЛ КОД С ФАЙЛА test.ru/2.php? ?>");
fclose($f);
$f = fopen("/path/to/1.php", "w");
$g = fopen("/path/to/2.php", "r");
stream_copy_to_stream($g, $f);
fclose($g);
fclose($f);