Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to generate html File in PHP

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to generate html files in PHP", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to generate html files in PHP" article.

The related implementation methods of generating html files by PHP.

How to use PHP ini_set function correctly

The PHP function ini_get_all gets the side of the set option variable

How to correctly realize the requirement of converting PHP string to numeric value

Sort the array of php by the length of the string

Sharing the specific skills of using PHP function ob_star ()

PHP generates html file 1, here is a method of using templates!

< ?php $fp = fopen ("templets.html","a"); if ($fp){ $fup = fread ($fp,filesize ("templets.html")); $fp2 = fopen ("html.shtml","w"); if ($fwrite ($fp2,$fup)){ $fclose ($fp); $fcolse ($fp2); die ("写入模板成功"); } else { fclose ($fp); die ("写入模板失败!"); } } ?>

< ?php $fp = fopen ("templets.html","a"); if ($fp) { $fup = fread ($fp,filesize("templets.html")); $fp2 = fopen ("html.shtml","w"); if ($fwrite ($fp2,$fup)) { $fclose ($fp); $fcolse ($fp2); die ("写入模板成功"); } else { fclose ($fp); die ("写入模板失败!"); } } ?>

Simply write the template into a file and save it as html.html

PHP generates html file 2 and generates html file name according to time

< ?php $content = "这是一个以日期时间为文件名 的静态生成网页的测试文件,文件名格式一 般为< font color=#ff0000>

Year, month, day, hour, minute and second

.html

< /font>

"

$datedate = date ('YmdHis')

$fp = fopen (date ('YmdHis'). '.html', "w")

/ / this function can be used to open the local or remote file'w'.

The file is opened by writing, and the file pointer points to the beginning.

And set the length of the original file to 0. If the file does not exist, a new file is created.

If (fwrite ($fp,$content)) {

/ / format is .int fwrite (int fp (file name)

String string (content), int [length]

(length); this function writes the string string to the file

On the pointer fp of the stream. If there is a specified length length

The specified length string is written, or until the end of the string.

Fclose ($fp); / / function is used to close open text

The pointer fp of the. True is returned for success and false for failure.

Die ("template written successfully")

}

Else {

Fclose ($fp)

Die ("failed to write template!")

}

Echo ($content)

? >

< ?php $content = "这是一个以日期时间为文件名 的静态生成网页的测试文件,文件名格式一般为 < font color=#ff0000>

Year, month, day, hour, minute and second. Html

< /font>

"

$datedate = date ('YmdHis')

$fp = fopen (date ('YmdHis'). '.html', "w")

/ / this function can be used to open the local or remote file'w'.

The file is opened by writing, and the file pointer points to the beginning.

And set the length of the original file to 0. If the file does not exist, a new file is created.

If (fwrite ($fp,$content))

{/ / format is .int fwrite (int fp (file name)

String string (content), int [length] (length))

This function writes the string string to the pointer fp of the file stream.

If there is a specified length length, the specified length string will be written

Or write to the end of the string. Fclose ($fp)

The / / function is used to close the pointer fp of an open file.

True is returned for success and false for failure.

Die ("template written successfully");}

Else {fclose ($fp); die ("failed to write template!")

}

Echo ($content);? >

PHP generates html file 3. Here is a way to convert the file name

< ?php $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); ?>

< ?php $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); ?>

The above is about the content of this article on "how to generate html files in PHP". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report