php用file_get_contents读取文件问题 在一个PHP文件中用file_get_contents读取一个静态的HTML文件,然后用ECHO显示出来,但显示出来时会自动在最前面加了个空格,但查看HTML源代码时,又找不到这个空格。为什么?哪位高人指点一二 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.biuuu.com/p819.html这个人的问题和我的情况很像,php赋值会产生额外的输出吗?应该怎么解决? iconv("gb2312","UTF-8",$content);用法错误,反过来iconv("UTF-8","gb2312",$content); 1.file_get_contentsPHP代码 1. <?php 2. $url = http://www.xxx.com/; 3. $contents = file_get_contents($url); 4. //如果出现中文乱码使用下面代码 5. //$getcontent = iconv("gb2312", "utf-8",file_get_contents($url)); 6. //echo $getcontent; 7. echo $contents; 8. ?> 2.curlPHP代码 1. <?php 2. $url = "http://www.xxx.com/"; 3. $ch = curl_init(); 4. $timeout = 5; 5. curl_setopt($ch, CURLOPT_URL, $url); 6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 7. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 8. //在需要用户检测的网页里需要增加下面两行 9. //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 10. //curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD); 11. $contents = curl_exec($ch); 12. curl_close($ch); 13. echo $contents; 14. ?>3.fopen->fread->fclosePHP代码 1. <?php 2. $handle = fopen ("http://www.xxx.com/", "rb"); 3. $contents = ""; 4. do { 5. $data = fread($handle, 8192); 6. if (strlen($data) == 0) { 7. break; 8. } 9. $contents .= $data; 10. } while(true); 11. fclose ($handle); 12. echo $contents; 13. ?> 还是编码问题 Fatal error: This file has expired 如何用PHP把繁体转换成简体 如何得到二维数组中同一名称元素的数值 作用域分辨运算符(::) 数组问题,求教???高手看过来 PHP能像ASP一样直接能够操作数据库(ACCESS)类的! 在PHP中如何获取主机端时间及客户端IP地址? SlightPHP框架的PHP网站转移到IIS下如何配置 学习途中遇到一个困惑我的问题,有关异常处理机制 布置网页问题 PHP 二维数组 输出的问题
iconv("UTF-8","gb2312",$content);
PHP代码 1. <?php
2. $url = http://www.xxx.com/;
3. $contents = file_get_contents($url);
4. //如果出现中文乱码使用下面代码
5. //$getcontent = iconv("gb2312", "utf-8",file_get_contents($url));
6. //echo $getcontent;
7. echo $contents;
8. ?> 2.curl
PHP代码 1. <?php
2. $url = "http://www.xxx.com/";
3. $ch = curl_init();
4. $timeout = 5;
5. curl_setopt($ch, CURLOPT_URL, $url);
6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
7. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
8. //在需要用户检测的网页里需要增加下面两行
9. //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
10. //curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);
11. $contents = curl_exec($ch);
12. curl_close($ch);
13. echo $contents;
14. ?>3.fopen->fread->fclose
PHP代码 1. <?php
2. $handle = fopen ("http://www.xxx.com/", "rb");
3. $contents = "";
4. do {
5. $data = fread($handle, 8192);
6. if (strlen($data) == 0) {
7. break;
8. }
9. $contents .= $data;
10. } while(true);
11. fclose ($handle);
12. echo $contents;
13. ?>