2014-02-08 84 views
0

我試圖用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(); 
} 

回答

0

你得到的一切兩次,因爲你echo兩次。

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

應該工作

+0

現在這個現在無法正常工作$輸出= $ tags-> handle_output($輸出); – user3274509

+0

實際上不會替換標題等... – user3274509

+1

ups我的錯誤:) – user3274509