【php写的一个生成静态页面的类】教程文章相关的互联网学习教程文章

php写的一个生成静态页面的类

/** 功能:生成静态页面 整理:脚本学堂 bbs.it-home.org 日期:2013-2-16*/class html{var $dir; //dir for the htmls(without/)var $rootdir; //root of html files(without/):htmlvar $name; //html文件存放路径var $dirname; //指定的文件夹名称var $url; //获取html文件信息的来源网页地址var $time; //html文件信息填加时的时间var $dirtype; //目录存放方式:year,month,,,,var $nametype; //html文件命名方式:namefuncti...

php生成静态页面函数(php2html)的例子

/**------------------------Function: php2html($in_Url, $out_htmlFile, $out_logFile)------------------------@ Description: 生成静态函数@ Copyright: Copyright (c) 2006 - 2011@ Create: 2006-08-01@ Modify: 2013-02-16@ 提示:路径为服务器绝对路径; 若给定的路径目录不存在则自动创建@ Example:php2html("http://bbs.it-home.org", "/www/html/index.html", "/www/log/log.txt");*/// {{{ contentsfunction php2html($i...

虚拟主机上定时自动生成静态页面的方法

$nowtime=time();$pastsec = $nowtime – $_GET["t"];if($pastsec{exit; //1分钟更新一次,时间可以自己调整}ob_start(); //打开缓冲区include(”index.php”);$content = ob_get_contents(); //得到缓冲区的内容$content .= “n”; //加上调用更新程序的代码file_put_contents(”index.html”,$content);if (!function_exists(”file_get_contents”)){function file_get_contents($fn,$fs){$fp=fopen($fn,”w+”);fputs($fp,$fs)...

php生成静态文件的二种方法

ob_start();#开启服务器缓存include_once 'Index.php';$ctx=ob_get_contents();#获取缓存ob_end_clean();#清空缓存$fh=fopen("index.html","w+");fwrite($fh,$ctx);#写入html,生成htmlfclose($fh);?>方法2:php 静态文件生成类class CreateHtml{function mkdir( $prefix= 'article' ){$y = date('Y');$m = date('m');$d = date('d');$p=DIRECTORY_SEPARATOR;$filePath='article'.$p.$y.$p.$m.$p.$d;$a=explode($p,$filePath);fore...

php生成静态页面的详细教程

{ title }this is a { file } files templets PHP处理:templetest.php$title = "测试模板";$file = "TwoMax Inter test templet,author:Matrix@Two_Max"; $fp = fopen ("temp.html","r");$content = fread ($fp,filesize ("temp.html"));$content .= str_replace ("{ file }",$file,$content);$content .= str_replace ("{ title }",$title,$content);echo $content;?>   模板解析处理,即将经PHP脚本解析处理后得出的结果填充...

php生成静态页面的三种方法与代码详解

ob_start();@readfile("http://bbs.it-home.org/");$text = ob_get_flush();$myfile = fopen("myfile.html","w");$text =str_replace ("{counent}",$string,$text);fwrite($myfile,$text);ob_clean();?>因为就算要生成静态页面,动态读取那部分也是要保留的,把数据插入数据库后,把url传递给readfile函数,然后读入缓存,fwrite一下就可以生成静态页面,这个是驼驼最欣赏的一种作法。代码行数最少,效率最高。http://bbs.it-home....

php使用ftp函数创建目录(生成静态)

/*** desc:create directory through FTP connection* link:bbs.it-home.org* date:2013/02/24*/function FtpMkdir($path, $newDir) { $server='ftp.yourserver.com'; // ftp server $connection = ftp_connect($server); // connection // login to ftp server $user = "me"; $pass = "password"; $result = ftp_login($connection, $user, $pass); // check if connection was made if ((!$conn...

php生成静态html文件的原理分析

//引入数据库配置文件include( dirname(dirname(__FILE__))."\include\config.php" );/**** 将数据库中的文章生成单个HTML文件.* @param Date $Date* @param Time $Time* @param String $Content* @param String $Title*/function GenerateHTML($Date,$Time,$Content,$Title,$Name){//将日期、时间变量分解成数组$GetDateRow = explode("-", $Date);$GetTimeRow = explode(":",$Time);//得到文件的名字。比如:20121028210632.html...

定时生成静态页面(PHP和ASP版)【图】

使用方法:在网站的流量大的页面,一般为首页用 iframe 调用上面的代码即可,如插入 转载地址: http://blog.qita.in/?post=327 很多时候,我们需要用到定时生成html页面的功能,原理简介:利用文件如index.html的最后修改时间和当前的时间做比较,当时间差超过一定间隔如2小时,则调用相关页面进行生成新页面。原始源代码如下。 PHP版本的的定时生成页面的:$file = dirname(__FILE__).'/index.html';$timex=time()-filem...

有关smarty模板引擎生成静态页的关键代码

本文介绍下,smarty模板引擎中,生成静态页的关键代码,有需要的朋友,参考下吧。在smarty中有一个获取模板页内容方法fetch(), 它的声明原形为:代码说明: 第一个参数为模板名称, 第二个参数为缓存的id, 第三个参数为编译id, 第四个参数为是否显示模板内容。 生成静态页,就需要用到这个方法。fetch(’模板名称.tpl’, null, null, false); //将内容写入至一个静态文件 $fp=fopen(’news.html’,'w’); fwrite($fp,$content); fc...

php定时生成静态html的代码分享

本文介绍下,用php定时生成静态html首页的一例代码,有需要的朋友参考下。用php定时生成静态页面。 代码如下:start(); //打开缓冲区 include(”index.php”); $content = ob_get_contents(); //得到缓冲区的内容 $content .= “n”; //加上调用更新程序的代码file_put_contents(”index.html”,$content);if (!function_exists(”file_put_contents”)) {function file_put_contents($fn,$fs){$fp=fopen($fn,”w+”);fputs($fp,$f...

PHP生成静态文件简单示例

<?php/** * @desc 生成静态文件时使用 * @todo htmlcache * @param $root string html文件存放路径 * @param $rule string html文件命名规则 * @param $url string 需要生成HTML文件的**页地址 * @return boole true/false */ public function setHtmlCache($root,$rule,$url){ //检测是否生成过静态文件 if (file_exists($root.$rule..html)){//已经存在静态文件 @unlink($root.$rule..html);//删除静态文件 return file_put_cont...

php结合smarty生成静态页面php文章内分页代码

本文介绍了php中使用smarty模板引擎生成静态页面的方法,以及php实现文章分页的实现代码,需要的朋友参考下。 例子,php中smarty生成静态页、文章内分页代码。专题:php分页代码原理',$content);$num = 0;foreach ($temp as $key => $val ) {$num++;$pagenav = '';if ($key == 0) {$file_name = '../html/'.$article_id.'.html';} else {$file_name = '../html/'.$article_id.'_'.($key+1).'.html';}for ($i=1;$i{$i} ";}else{if (...

php生成静态html文件的三种方法

$fp = fopen ("templets.html","a");if ($fp){$fup = fread ($fp,filesize("templets.html"));$fp2 = fopen ("html.shtml","w");if ($fwrite ($fp2,$fup)){$fclose ($fp);$fcolse ($fp2);die ("写入模板成功");} else {fclose ($fp);die ("写入模板失败!");}}?> 将模板写进一个文件,保存为html.html。 方法2,按时间生成html文件名$content = "这是一个以日期时间为文件名的静态生成网页的测试文件,文件名格式一般为年月日时分秒....

利用PHP语言生成静态页面要怎么做?【图】

在PHP网络开发和搜索引擎优化网站推广等方面的需求,需要对空间站的网站或当地的静电处理,PHP生成静态HTML页面有多种方法,如使用PHP模板,缓存静态页面来实现,今天到php实例教程讨论如何形成的PHP生成静态页面。静态页面的方法,分为两种类型,一种是伪静态,即是URL重写,一个是你真正的静态。在这里,小编讲解PHP静态页面的方法。什么是php静态化PHP静态化的简单理解就是使网站生成页面以静态HTML的形式展现在访客面前,PHP静...