2016-11-19 65 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