.PHP生成静态html文件的方法 1,下面使用模版的一个方法! $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 = "这是一个以日期...
示例代码: require(libs/Smarty.class.php); $tpl=new Smarty(); $tpl->template_dir=./templates/; $tpl->compile_dir=./templates_c; $tpl->config_di示例代码: require(libs/Smarty.class.php); $tpl=new Smarty(); $tpl->template_dir=./templates/; $tpl->compile_dir=./templates_c; $tpl->config_dir=./config/; $tpl->cache_dir=./cache/; $tpl->left_delimiter=<{; $tpl->right_delimiter=}>; ob_start(); //打开输出缓...
/** * Miscellaneous utility methods. */final class Utils { private function __construct() { }/** * Redirect to the given page. * @param type $page target page * @param array $params page parameters */ public static function redirect($page, $sub_page = null, array $params = array()) { header('Location: ' . self::createLink($page, $sub_page, $params)); die(...
/** 创建目录*/function makedir($mudir){$file = "./$mudir";@mkdir($file,0777);}/**先创子摸板文件路径*/function writemod($filemodname) {$fp=fopen("showmod.shtml","r");$str=fread($fp,filesize("showmod.shtml"));fclose($fp);$fp=fopen($filemodname,"w");fwrite($fp,$str);fclose($fp);}/**更新各自的子摸板文件//$modfile是子摸板名字*/function writeweb($content,$web,$modfile){$fp=fopen($modfile,"r");$str=fread...
/** 功能:生成静态页面 整理:脚本学堂 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...
/**------------------------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)...
//////////// 张树林 - 慧佳工作室//// Module Name: woods-bhtml.php// Abstract: 生成静态HTML处理程序尾底// Version: 2.0// 版权 1001-1006,慧佳工作室所有版权保护//The software for free software, allowing use, copy,//modify and distribute the software and files. Any//use of this software must place a copy of all the//above copyright notice. By the software Huijia studio//maintenance, if you have any q...
require_once("conn.php");if($_GET['all']){/*获取数据库记录,以便于生成html文件有个文件名*/$sqlquery = "select * from $tbname";$result = mysql_query($sqlquery,$conn)or die("查询失败!");$fp = fopen("./template/article.html",r);$fpcontent = fread($fp,filesize("./template/article.html"));fclose($fp);/*写入文件*/while($row = mysql_fetch_array($result)){$fpcontent = str_replace("{thetitle}",$row['title'...
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...
{ 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脚本解析处理后得出的结果填充...
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....
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.+) index.php/$1 [L] 上面的代码就是将URL结构导入index.php中,具体的rewrite细节就不赘述了。 2.在PHP中设置一个路由规则配置文件routes.php,我简单的使用了一个hash数组编写规则: /** *路由配置文件编写说明: * 路由配置在一个array...
/*** 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...
//画一个很漂亮的叶子// 定义 PI 一分的角度的值define("PII", M_PI/180);// 新建图像资源,并定义其背景为 白色,前景色为 黑色$im = imagecreate(670,500);$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);$g = imagecolorallocate($im, 0x00, 0x00, 0x00);// 从下面实例化的代码可以得知,初始值 $x, $y, $L, $a 别分为 300, 500, 100, 270function drawLeaf($g, $x, $y, $L, $a) {global $im;$B = 50;$C = 9;$s1 = 2;$s2 ...