Home  >  Article  >  php教程  >  php 生成静态html

php 生成静态html

WBOY
WBOYOriginal
2016-06-13 10:47:40758browse

require "comm.php"; 
if(isset($_POST['submit'])){ 
    $title=$_POST['title']; 
    $content=$_POST['content']; 
    $addtime=time(); 
    $sql="insert into news (title,content,addtime) values ('$title','$content','$addtime')"; 
    $rs=$db->query($sql); 
    if($rs){ 
        $time=date('ymd'); 
        $tmp=$_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/'.$time.$title.'.'.html; 
        $fp=fopen($tmp,'w'); 
        $tmpT=$_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']).'/tmp.html'; 
        $fpT=fopen($tmpT,'r'); 
        $str=fread($fpT,filesize($tmpT)); 
        $str=str_replace('{title}',$title,$str); 
        $str=str_replace('{content}',$content,$str); 
        fwrite($fp,$str); 
        fclose($fp); 
        fclose($fpT); 
        echo "OK"; 
    } 

//==================================  
echo "
"; 
echo $_SERVER['DOCUMENT_ROOT']; 
echo "
"; 
echo $_SERVER['PHP_SELF']; 
echo "
"; 
echo date('ymd'); 
echo "
"; 
echo  dirname($_SERVER['PHP_SELF']); 
?> 
  

  
  
  
  
  
 
  
 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php 文章管理Next article:php简单分页类