Two PHP tutorials to generate HTML page implementation code
Open file form with fopen fread fwrite fcolse
$fp = fopen ("templets.html", "a");
if ($fp) {
$fup = Fread ($fp, FileSize ("templets.html"));
$FP 2 = fopen ("html.shtml", "w");
if ($fwrite ($fp 2, $fup)) {
$fclose ($FP);
$fcolse ($fp 2);
Die ("Write template Success");
} else {
Fclose ($FP);
Die ("Write template failed!");
}
}
?>
PHP read the file, Fread is used to read the contents of the file opened with fopen, let's take a look at the fread and get instance tutorial.
Definition and usage
The Fread () function reads the file (which can be used safely in binary files).
Grammar
Fread (file,length) parameter description
File required. Specifies to read open files.
Length required. Specifies the maximum number of bytes to read.
Description
Fread () reads up to length bytes from file pointer files. The function stops reading the file when it has read up to the maximum length of bytes, or when it reaches EOF, or (for a network stream) when a package is available, or when 8,192 bytes have been read (after opening a stream of user space), depending on which situation is encountered first.
$file = fopen ("Test.txt", "R");
Fread ($file, FileSize ("test.txt"));
Fclose ($file);
?>
For more detailed information, please see: http://www.bKjia.c0m/phper/18/753bc9c01fa5a721a81c63887ddccb47.htm
Cache output Ob_end_clean Ob_start ob_get_length ob_get_contents function
$s _fname = "93e.php";
$o _fname = "93e.htm";
Ob_end_clean ();
Ob_start ();
Include ($s _fname);
$length = Ob_get_length ();
$buffer = Ob_get_contents ();
$buffer = Eregi_replace ("R", "", $buffer);
Ob_end_clean ();
$fp = fopen ($o _fname, "w+");
Fwrite ($fp, $buffer);
Fclose ($FP);
?>
Three functions: "Ob_start (), Ob_end_clean (), ob_get_contents ()"
Ob_start (): is to open the buffer, is to put the static file you need to generate the contents of the cache here;
Ob_get_contents (): is to read out the contents of the buffer, the following code for example;
Ob_end_clean (): This is more important, only after using this function, the contents of the buffer will be read out
For more detailed information, please see: http://www.bKjia.c0m/phper/php-cy/35433.htm
http://www.bkjia.com/PHPjc/631729.html www.bkjia.com true http://www.bkjia.com/PHPjc/631729.html techarticle two PHP tutorials generate HTML page implementation code using fopen fread fwrite fcolse open file form? php $fp = fopen (Templets.html,a), if ($fp) {$fup = Fread ($fp, FileSize (templets.html ...