代码之家  ›  专栏  ›  技术社区  ›  user3274509

替换链接功能

  •  0
  • user3274509  · 技术社区  · 11 年前

    我正在尝试用ob_get_contents()替换链接,但我正在使用另一个函数替换标题标签,如title等。。。 使用此代码,我得到了双页眉、索引和页脚。

    作用

    function self_urls_convert($html) { 
      $html = str_replace('index.php','index',$html);
      $html = str_replace('about_us.php','about_us',$html);
      return $html;
    }
    

    页脚

    $output = ob_get_contents();
    
    if (ob_get_length() !== FALSE){
      ob_end_clean();
    }
    
    echo self_urls_convert($output);
    echo $tags->handle_output($output); 
    
    if (ob_get_length() !== FALSE){
      ob_end_flush();
    }
    
    1 回复  |  直到 11 年前
        1
  •  0
  •   kero    11 年前

    你得到了一切,因为你 echo 两次。

    $output = self_urls_convert($output);
    $output = $tags->handle_output($output);
    echo $output;
    

    应该工作

    推荐文章