Ideas
Use the fopen function and fread function to obtain the template, replace the template tag with the str_replace function as the variable, and use the fwrite function to output a new HTML page.
Index.html template page
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<? Header ('content-Type: text/html; charset = UTF-8 '); $ conn = mysql_connect ('localhost', 'root ',''); $ db = mysql_select_db ('bbs ', $ conn); mysql_query ('set names utf8'); $ SQL = "select * from notice "; $ query = mysql_query ($ SQL); // print_r ($ arr); while ($ arr = mysql_fetch_array ($ query) {$ title = $ arr [title]; $ content = $ arr [content]; $ file = "index.html"; $ neirong = $ arr [id]. ". html "; $ fp = fopen ($ file, 'R'); $ ht = fread ($ fp, fil Esize ($ file); $ str = str_replace ('{title}', $ title, $ ht); $ str = str_replace ('{content}', $ content, $ str); fclose ($ file); $ file = fopen ($ neirong, 'w'); $ write = fwrite ($ file, $ str);}?>
Author's "PHP Study Notes"