Home > Backend Development > PHP Tutorial > php 怎么把得到的文件名编码换一下?

php 怎么把得到的文件名编码换一下?

WBOY
Release: 2016-06-06 20:07:21
Original
1099 people have browsed it

<code><?php $path="C:/AppServ/www/YB-PHP";
$d=opendir($path);//把目录打开为资源
while( $a = readdir($d))
{
    echo $a."<br>";
}
</code>
Copy after login
Copy after login

echo :

<code>.
..
.project
1.jpg
br_ .php
class
example
file_example
mysql-example
path_demo
PDO-example
PDO-PHP-HTML
PHP-FORM
ShiYan
xdl
xsphp
�½��ļ���</code>
Copy after login
Copy after login

这个 �½��ļ��� 就是 新建文件夹..
怎么换换编码?

回复内容:

<code><?php $path="C:/AppServ/www/YB-PHP";
$d=opendir($path);//把目录打开为资源
while( $a = readdir($d))
{
    echo $a."<br>";
}
</code>
Copy after login
Copy after login

echo :

<code>.
..
.project
1.jpg
br_ .php
class
example
file_example
mysql-example
path_demo
PDO-example
PDO-PHP-HTML
PHP-FORM
ShiYan
xdl
xsphp
�½��ļ���</code>
Copy after login
Copy after login

这个 �½��ļ��� 就是 新建文件夹..
怎么换换编码?

<code><?php /**
 * 关注微信公众号:phpgod(PHP技术大全,每日精彩技术分享).
 */
header("Content-Type:text/html;charset=GB2312");

$directoryResource = opendir(".");
while($directory = readdir($directoryResource)){
    echo $directory."<br/>";
}</code>
Copy after login

<code>$content = iconv("GBK", "UTF-8", $content); 
$content = mb_convert_encoding($content, "UTF-8","GBK");

可以使用这个PHP函数转码,但是mb_convert_encoding()这个函数,需要开启php.ini的PHP扩展</code>
Copy after login

header设置一下

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template