/    Sign up×
Community /Pin to ProfileBookmark

Working with Files

Hello:

After a script finishes processing a form, I would like to take the web page which it produces and save it as an HTML file.

Can I do this? And if so, how?

Thank you for the help.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderApr 23.2007 — I think your looking for ob_start(), ob_get_clean() and the basic fopen(), fwrite() and fclose() functions?
Copy linkTweet thisAlerts:
@focus310authorApr 23.2007 — Hi,

I'm not quite sure what I need. All I want to do is process a script and save the web page which displays the results as a file.

When I read about fopen(), it sounded to me that the file already exists. I'm trying to create a brand new file.

Will this function create a new file?

Thanks.
Copy linkTweet thisAlerts:
@MrCoderApr 23.2007 — Yes by passing "w" as the second parameter.

[code=php]
<?php
ob_start();
?>

<h1>Place your form output here, this will get saved in the page.html file</h2>

<?php
$html = ob_get_clean();

$file = fopen("page.html", "w");
fwrite($file, $html);
fclose($file);
?>
[/code]
Copy linkTweet thisAlerts:
@focus310authorApr 23.2007 — Thank you for the info. I'll give it a try.
×

Success!

Help @focus310 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...