2016-11-19 112 views
0

數據庫生成的頁面將被保存爲靜態頁面,但頁面內的url本身需要重寫。功能是已經作出。PHP頁面的循環內容,製作並保持更改

- >我得到了一個錯誤:破滅():無效的參數傳遞

目標:本網站將在3種語言,但他們都使用相同的頁面的index.php。所以這對谷歌來說不夠好。所以靜態頁面將被生成,每種語言都會有自己的文件夾。

當頁面被提取時,我會在提取的內容的代碼中做一些url重寫。 (不僅僅是.htaccess的網址重寫。這根本不是重點。) 頁面將完全更改名稱,併成爲一個靜態頁面。
我希望這已經夠清楚了。希望有人找到一種方式,我嘗試了這麼多,我幾乎失去了完成這一任務的希望。

//At the beginning of the page above the HTML tag. 
//Destination for the page and the new name for the page. 

$cachefile = "../".trim($_GET['lang'])."/".trim($_GET['page']).".php"; 

ob_start(); 

<html> 
<body> 
... 
</body> 
</html> 

// At the end of the page 
$content = ob_get_contents(); 


// here the loop with my function to find an url 

$content = ob_get_contents(); 

$arrcontent = explode(" ",$content); 

$newcontent=""; 

foreach($arrcontent as $value){ 

    $value = replaceurl_newurlmenu($value, $pathwebsite, $pathmenu); 

    $newcontent .= array($value);  

} 

$content = implode(" ",$newcontent); 



// then write everything to a page at a new destination 

$fp = fopen($cachefile, 'w');  
fwrite($fp, $content);  
fclose($fp);  

ob_end_flush(); 
+0

你可能要考慮使用元數據標籤的SEO。即:'Content-Language:en,hi,pa' – yardpenalty

+1

或者多語言博客或CMS – user2182349

+0

@ user2182349如果有其他人提供了該網站,有什麼樂趣? – FreeSpirit

回答

0

要解決你有什麼

$arrcontent = explode(" ",$content); 

$newcontent=array(); 

foreach($arrcontent as $value){ 

$value = replaceurl_newurlmenu($value, $pathwebsite, $pathmenu); 

$newcontent[] = $value;  

} 

$content = implode(" ",$newcontent); 

不過,我會考慮在array_walk方法尋找了。

+0

嘿,這工作得很好。謝謝,我知道它與數組有關,但不知道如何。再次感謝。 – FreeSpirit

+0

不要忘了點擊複選標記標記爲答案。很高興你的問題解決了。 – yardpenalty