Home > Backend Development > PHP Tutorial > PHP template tag introductory tutorial [file_get_content]_PHP tutorial

PHP template tag introductory tutorial [file_get_content]_PHP tutorial

WBOY
Release: 2016-07-20 11:06:18
Original
1208 people have browsed it

本文章是利用了php的fso功能读取模板文件,然后根据我处自定义好的标签进行了文件模板替换就OK了。

本文章是利用了php的fso功能读取模板文件,然后根据我处自定义好的标签进行了文件模板替换就OK了。

function GetContent($type){
  if( $type )
  {
   if(file_exists('./mail_room.html') )
   {
    $content = file_get_contents( './mail_room.html');
   }
   else
   {
    ShowMsg('file can' read fail ');
   }
  }
  else
  {
   if( file_exists( './mail_person.html') )
   {
    $content = file_get_contents( './mail_person.html');
   }
   else
   {
    ShowMsg('person file read fail!');
   }
   
  }
  return $content;
 }
 
 function template($str)
 {
  $_url = $_SERVER['HTTP_HOST'];
  $_temp = str_replace('{username}',$_SESSION['uname'],$str);
  $_temp = str_replace('[bgpic]',getPic(),$_temp);
  $_temp = str_replace('{url}',$_url,$_temp);
  return $_temp;
 }

我们来看看模板文件





 
  



  

       

  •                                                                               
                                                                                                                                                                                🎜>                                                                                                                 
  • The relationship between trendy foods and childhood diseases

  •                                                                                                     /a> 🎜>                                                                                                                               20px;">I found a celebrity baby,
            Hurry Come and take a photo together!


                                                                             



    http://www.bkjia.com/PHPjc/445045.html

    www.bkjia.com

    true

    http: //www.bkjia.com/PHPjc/445045.html

    TechArticle

    This article uses the fso function of php to read the template file, and then proceeds according to the tags customized by us. The file template replacement is OK. This article uses the fso function of php to read templates...


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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template