<div class="linkL">STRAŠNI MIKROSKOP</div>
<?php
$chapter = "chapters/" . $_GET["ch"] . ".php";
include $chapter;
?>
JS
$(".linkL").click(function() {
var a = $(this).html();
var b = a.split(' ').join('-');
var c = b.toLowerCase();
location.href = "index.php?ch=" + c;
});
點擊地址欄後,我有index.php?ch=strašni-mikroskop
。沒關係,但文件chapters/strašni-mikroskop
不包括在內!?
如果我用s
替換š
- 一切正常。
那麼,我怎樣才能使用上面的代碼使用š
unicode字符?
所有文件都編碼爲utf8。
嘗試'$ chapter = rawurlencode(「chapters /」。$ _GET [「ch」]。「.php」);' – Michel 2014-10-17 11:05:45
@Michel,謝謝,但它不起作用。 – bonaca 2014-10-17 11:15:52
這可能是您的服務器不喜歡文件和文件夾名稱中的特殊字符。嘗試在js中對鏈接進行硬編碼('location.href =「index.php?ch =strašni-mikroskop」;')如果它仍然不起作用,那可能是服務器。 – Michel 2014-10-17 11:24:47