楼主可以尝试一下smarty,功能更全,可以输出更复杂的内容。

解决方案 »

  1.   

    这么做,我感觉不太好啊?比如你有一个
    index.php文件,
    要想把他生成静态页面,
    第一:需要建立一个index_template.html的模板文件
    第二:需要建立一个index_index.php的模板解析文件,
      

  2.   

    静态页面适用于时效性比较高,内容变动比较小的情况,比如说新闻.
    一般利用模板文件,生成一个xxx.html的实体文件.而对内容变化比较频繁的情况,一般不生成静态页面,而是利用模板在页面生成时,动态替换.这两种情况还是有点区别的.
      

  3.   

    这种生成方式用smarty等模板引擎协助会更好一些。
      

  4.   

    如果页面完全静态的话,哪就如楼主所言.
    这个问题是比较头疼的问题.如果记录频繁增加,列表页完全静态,静态的工作量的确很大.
    但我有一个想法:
    可否这样,如果一个列表页20条记录,当新添加的记录只有到20条以后,就新建个列表页.其它的列表页只需要更新分页部分的html. 如果列表页分页部分的html是动态的话,则可不更新.对于不足20条的记录,则可以认为是新添加的记录,重新开个记录页.
      

  5.   

    写一个函数,一次解析所有变量protected  function parse_template($str="",$arr = array())
    {
    $this->template_vars = $arr;

    if(is_file($str))
    $template_str = file_get_contents($str);  
    else
    $template_str = $str; 

    if($this->template_vars)
    {
    $template_str = preg_replace_callback('|\{(\$.+?)\}|is',array($this,"parse_template_callback"),$template_str);
    }
    return $template_str; 

    }

    protected function parse_template_callback($matches)
    {
    extract($this->template_vars); 
    $temp_vars = $matches[1];
    eval("\$temp_vars= ".$temp_vars.";");
    return $temp_vars;
      

  6.   

    你的动态->静态没有数据库支持的啊?要你一个一个写列表项啊?在smarty语法中,从数据库中获得一个记录集后用下列的语法就可以遍历:<ul>
    {section name=list loop=$lists}
    <li>{$lists[list].id}: {$lists[list].description}</li>
    </section>
    </ul>哪里麻烦?
      

  7.   

    PHP中这样写:<?php$lists=array();
    $i=0;
    while($row=mysql_fetch_assoc($res))
    {
       $lists[$i]['id']=$row['id'];
       $lists[$i]['description']=$row['description'];   $i++;
    }$sm->assign('lists', $lists);$sm->display('index.tpl');
    ?>