Home > php教程 > php手册 > body text

php 生成静态html

WBOY
Release: 2016-06-13 10:47:40
Original
758 people have browsed it

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']); 
?> 
  

  
  
  
  
  
 
  
 
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!