2011-12-20 47 views
0

我的網址更改爲Seo使用此功能友好+ .htaccess。我的項目採用阿拉伯語言!Unicode/UTF Seo Friendly Url(slug)使用Php Mysql

function clean($title) { 

$seo_st = str_replace(' ', '-', $title); 
$seo_alm = str_replace('--', '-', $seo_st); 
$title_seo = strtolower(str_replace(' ', '', $seo_alm)); 

return $title_seo;} 

現在在我的網址我看到這一點:

本地主機/新聞/ 4/----- /

什麼問題?

感謝

回答

0

檢查,如果你的數據庫字段collation已正確設置爲UTF-8,和您的連接是UTF-8 SET NAMES "utf8"

如果您在腳本中使用任何來自值的字符,請確保它們是UTF-8。在做任何事情之前在你的代碼

+0

在我的配置中:mysql_query(「SET NAMES'utf8'」);和我的排序規則:utf8_persian_ci – user1086738 2011-12-20 00:25:46

+0

然後調試你的鏈,找出角色何時變壞。 – Halcyon 2011-12-20 00:49:09

1

試試這個,告訴我,如果它的工作原理:

mb_internal_encoding("UTF-8"); 
mb_regex_encoding("UTF-8"); 
+0

已經在配置文件中。我將所有UTF-8代碼放入我的配置文件中。但我不知道有什麼問題。 – user1086738 2011-12-20 08:56:39

1

嘗試......

$dbconnect = @mysql_connect($server,$db_username,$db_password); 
$charset = @mysql_set_charset('utf8',$dbconnect); 


<head> 
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> 
</head> 
0

試試吧......我的作品

<?php 
 
    function clean_url($text) 
 
    { \t  
 
\t $code_entities_match = array(' ','&amp;','--','&quot;','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=','"'); 
 
\t $code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','',''); 
 
\t $text = str_replace($code_entities_match, $code_entities_replace, $text); 
 
\t return urlencode($text); \t 
 
    \t } 
 
?>