dqhgjay5753 2014-02-09 11:48
浏览 38

Php动态Breadcrumb非英文字母编码

<?php
function breadcrumbs($home = 'Ana Sayfa') {
//Use RDFa breadcrumb, can also be used for microformats etc.
$bc     =   '';
$isaret = ' &raquo';
//Get the website:
$site   =   'http://'.$_SERVER['HTTP_HOST'];

//Get all vars en skip the empty ones
$crumbs =   array_filter( explode("/",$_SERVER["REQUEST_URI"]) );
//Create the home breadcrumb
$bc    .=   '<li><a href="'.$site.'" rel="v:url" property="v:title">'.$home.''.$isaret.'</a></li>'; 
//Count all not empty breadcrumbs
$nm     =   count($crumbs);
$i      =   1;
//Loop the crumbs
foreach($crumbs as $crumb){
    $link    =  ucfirst( str_replace( array(".php","-","_"), array(""," "," ") ,$crumb) );
    $site   .=  '/'.$crumb;
    //Make the next crumb
    $bc     .=  '<li><a href="'.$site.'" rel="v:url" property="v:title">'.$link.''.$isaret.'</a></li>';
    $i++;
}
$bc .=  '';
//Return the result
return $bc;}

?>

Hello There

I am using in my web sites this great Php dynamic bredcrump solution which was an answer in this post. Thank you for sharing. But i have a question;

In my site i am using Turkish language, and Turkish language has 7 non-english letter in it's alphaphet.so when the script copy the adress bar breadcrump shows only english compatible letters unfortunattely not turkish letters.

Question is : With this script is it possible the create a variable that allows to tweak and show created link's title in breadcrump menu

For example :

Adress Bar=

http://www.mamaia.com/tr/urunler/cocuk-uretimi-alcilar

Breadcrump = (should be)

Ana Sayfa > Tr > Ürünler > Çocuk Üretimi Alçılar

is there any suggestions?

  • 写回答

2条回答 默认 最新

  • dsc71976 2014-02-09 11:54
    关注

    1) Set content encoding inside <head></head> tags

    <meta charset="utf-8">
    

    2) Set this at the top

    setlocale(LC_ALL, 'tr_TR.UTF-8')
    

    3) If still problems, try

     echo utf8_encode($your_breadcrumb);
    
    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致