Saving a remote file via FTP with file_put_contents()
$page = file_get_contents('page-template.html');
$page = str_replace('{page_title}', 'Welcome', $page);
if (date('H' >= 12)) {
$page = str_replace('{color}', 'blue', $page);
} else {
$page = str_replace('{color}', 'green', $page);
}
$page = str_replace('{name}', $_SESSION['username'], $page);
file_put_contents('ftp://name:password@ftp.example.com/welcome.html', $page);
Related examples in the same category