Home > Backend Development > PHP Tutorial > php generates static html_PHP tutorial

php generates static html_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:49:15
Original
1087 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']); 
?> 
  
  
  
  
  
  
 

  
  新闻标题:
  
  新闻内容:
  
    
 
  
  
  
  
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']);
?>






 

  新闻标题:

  新闻内容:

 
 



 [html] //tmp.html 
  
  
  
{title}  
  
  
{content}  
  
   

摘自 chaojie2009的专栏

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478380.htmlTechArticle?php require comm.php; if(isset($_POST[submit])){ $title=$_POST[title]; $content=$_POST[content]; $addtime=time(); $sql=insert into news (title,content,addtime) values ($title,$cont...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template