rWanBoy 's BLOG [Welcome to my Blog]记录着点点滴滴,保存着许许多多

下面这段代码是不能够返回正确值的代码,无论文件是否在都返回不在:

 

下面这段代码是不能够返回正确值的代码,无论文件是否在都返回不在:

1
2
3
4
5
6
<?php;
$file="/attachment/21/0/中文.rar";
$newfile = dirname(__FILE__).$file;
 
echo file_exists($newfile);
?>

经过测试之后,增加了一句将UTF8编码转换为GB2312编码的语句,就可以正确判断了:

1
2
3
4
5
6
7
8
<?php
$file="/attachment/21/0/中文.rar";
$newfile = dirname(__FILE__).$file;
 
$file=iconv('UTF-8','GB2312',$file);
 
echo file_exists($newfile);
?>

2020年8月20日 | 发布:rwanboy | 分类:未分类 | 评论:0

发表留言: