Php > HTML and Php
Creating a html page on the fly
Creating a html page on the fly //create an html file and redirect to it //set some basic html content $sHTML_Header = "
Test an html page
"; $sHTML_Content = "
This is a Test Page
"; $sHTML_Footer = ""; $filename = "test.html"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $sHTML_Header) === FALSE) { echo "Cannot write to file ($filename)"; exit; }else{ //file is ok so write the other elements to it fwrite($handle, $sHTML_Content); fwrite($handle, $sHTML_Footer); } fclose($handle); }else{ echo "The file $filename is not writable"; } //redirect the user to the html page header("location:$filename"); ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage