2012-11-10 55 views
0

我使用URL参数在PHP中构建filebrowser,并遇到一些特殊字符问题。 我设法翻译成ß%26'%2C预期我的节奏蓝调文件夹输出R%2 CN%2CB但PHP说PHP URL GET字符集问题

警告:执行opendir(DIR // MUSIK/R,N ,B /,dir // Musik/R,n,B /)[function.opendir]:Das System can an diegegebene Datei nicht finden。 (代码:2)

我的代码片段:

function fileBrowser($dir, $file) { 
    $trans = array("&" => "%26","'" => "%2C"); 
    $cdir = strtr(@$_GET['dir'],$trans); 
    $cfile = strtr($file,$trans); 
... 

能否请你给我一个提示?

+2

有['urlencode()来'](http://php.net/urlencode),选择那些。但是,您现在是否生成一个URL,或者您是否尝试使用PHP文件功能访问它? (如果是这样,则不需要URL编码。) – mario

+0

谢谢,但现在我的问题得到了解答。 – Manticore

+1

谷歌“php unicode文件名”,你会得到一些有趣的结果。 – inhan

回答

1

我会建议使用urlencode/urldecode而不是自己替换它。

然而ß%C3%9F是和'%27

+0

%27帮助我。谢谢! – Manticore