so want to auto create a whole html page i was thinking like this

$newhtml = '<html><head></head><body>'.$variable.'</body></html>';
file_put_contents ('file.html',$newhtml);

this would be the proper thing to do?

Not really... I would separate it into a head, body and footer.

Then in my php I would include the header using include('head.php')
Another common practice is to create entire page templates.

Member Avatar

As iawmthwee states, you will probably have common features for all pages, such as footers, headers (banners, nav areas) and maybe side panels.

There are a number of ways to do this. You could do this for each 'page':

$page = basename($_SERVER['PHP_SELF']);
    require "includes/header.php";
    require "pages/$page";
    require "includes/footer.php";
    //provide a default page or set a 404

Just an example. That way you don't have to duplicate header, footer etc...