【问题标题】:Replace links function替换链接功能
【发布时间】:2014-02-08 15:37:14
【问题描述】:

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

功能

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();
}

【问题讨论】:

    标签: php output str-replace ob-get-contents


    【解决方案1】:

    你得到所有东西两次,因为你echo它两次。

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

    应该有效

    【讨论】:

    • 现在这行不通了 $output = $tags->handle_output($output);
    猜你喜欢
    • 2018-10-31
    • 2019-08-17
    • 2013-05-18
    • 2015-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多