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?
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.
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']);
if(file_exists("pages/$page"))
{
require "includes/header.php";
require "pages/$page";
require "includes/footer.php";
}else{
//provide a default page or set a 404
}
Just an example. That way you don't have to duplicate header, footer etc...
Thanks!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.