Web Analytics Made Easy -
StatCounter Saving a page on the server - CodingForum

Announcement

Collapse
No announcement yet.

Saving a page on the server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving a page on the server

    I'm not sure how to go about this, but what I would like to be able to do is this:

    Be able to parse a PHP page -- essentially generating an HTML page -- and saving that HTML/Javascript code somewhere on the server as an .HTML file (or .PHP or whatever...).

    Is this possible? In the sense that a user can press a button which would archive the data so that it would be permanent.

    I'm trying to devise a solution for retaining old data. Obviously there are two options:
    1. store it in the database
    2. store it outside of the database.

    With option 2, I'm wondering if I can just save the views that my clients will be interested in (and only those) as HTML files -- or even PDF or JPEG files if further possible -- and merely collecting a list of archived views (this list would have to be stored in the database).

    So basically, I'm just wondering if it is possible to save a parsed PHP document on the server as an HTML file, by the server, and how to go about doing that. Any pointers to online tutorials or a simple example would be greatly appreciated!

    If you need more information, please post and I will reply.

    Thanks,
    Sadiq.

  • #2
    step 1:
    generate the html as if you would sent it to the client, but instead of echoing it to the client, you store it inside a variable. Like if you normally would use
    echo('This is the first line'.);
    then you will now have
    $output .= ('This is the first line'.);

    Step 2:
    the create the file with fopen() in writing mode --> w or w+
    see http://be.php.net/function.fopen

    Step 3:
    dump the $output in the file and close it
    http://be.php.net/manual/en/function.fwrite.php
    http://be.php.net/manual/en/function.fclose.php
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X